note 24364 added to function.getdate

From: Date: Wed, 14 Aug 2002 10:56:36 +0000
Subject: note 24364 added to function.getdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-34993@lists.php.net to get a copy of this message
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"]; -- http://www.php.net/manual/en/function.getdate.php http://master.php.net/manage/user-notes.php?action=edit+24364 http://master.php.net/manage/user-notes.php?action=delete+24364 http://master.php.net/manage/user-notes.php?action=reject+24364

« previous php.notes (#34993) next »