note 31287 added to function.getdate
| From: | Joel at rack1 dot php dot net | Date: | Wed, 16 Apr 2003 12:37:15 +0000 |
| Subject: | note 31287 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46686@lists.php.net to get a copy of this message | ||
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"];
--
http://www.php.net/manual/en/function.getdate.php
http://master.php.net/manage/user-notes.php?action=edit+31287
http://master.php.net/manage/user-notes.php?action=delete+31287
http://master.php.net/manage/user-notes.php?action=reject+31287