note 43215 added to function.getdate
| From: | johndb8 at hotmail dot com | Date: | Mon, 14 Jun 2004 13:53:14 +0000 |
| Subject: | note 43215 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-71045@lists.php.net to get a copy of this message | ||
found on a mirror:
The following code will "zero-fill" the code, convert to a 12 hour time and add am/pm
support.
// get current date
$current = getdate();
// format
$current["hours"] = $current["hours"] + 1;
if ($current["hours"] < 13) {
$ampm = " AM";
}
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"];
----
Manual Page -- http://www.php.net/manual/en/function.getdate.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43215
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43215&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43215&report=yes
Search -- http://master.php.net/manage/user-notes.php