note 31287 deleted from function.getdate by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 15 Sep 2004 16:38:48 +0000 |
| Subject: | note 31287 deleted from function.getdate by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76760@lists.php.net to get a copy of this message | ||
Note Submitter: Joel Strellner
----
This is a correction to my post on 14-Aug-2002 07:56.
The code should have read (changed formatting and fixed a bug):
// get current date
$current = getdate();
// format
if ($current["hours"] < 12) {
$ampm = " AM";
}
elseif ($current["hours"] == 12) {
$ampm = " PM";
}
else {
$current["hours"] = $current["hours"] - 12;
$ampm = " PM";
}
if ($current["hours"] < 10) {
$current["hours"] = "0" . $current["hours"];
}
if ($current["minutes"] < 10) {
$current["minutes"] = "0" . $current["minutes"];
}
if ($current["seconds"] < 10) {
$current["seconds"] = "0" . $current["seconds"];
}
if ($current["mday"] < 10) {
$current["mday"] = "0" . $current["mday"];
}
// turn it into strings
$current_time = $current["hours"] . ":" . $current["minutes"] .
":" . $current ["seconds"] . $ampm;
$current_date = $current["month"] . " " . $current["mday"] .
"," . " " . $current["year"];