note 43215 deleted from function.getdate by victor
| From: | victor@php.net | Date: | Mon, 14 Jun 2004 14:13:11 +0000 |
| Subject: | note 43215 deleted from function.getdate by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71047@lists.php.net to get a copy of this message | ||
Note Submitter: johndb8@hotmail.com
----
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"];