note 35398 deleted from ref.datetime by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 17:40:59 +0000 |
| Subject: | note 35398 deleted from ref.datetime by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133184@lists.php.net to get a copy of this message | ||
Note Submitter: dkan at netscreen dot com
----
Zero-padding is easier to read and less complicated if you use the substr() function instead of an
if-then statement.
function printtime() {
$timenow = getdate();
$hours = substr("0" . $timenow["hours"], -2);
$minutes = substr("0" . $timenow["minutes"], -2);
$seconds = substr("0" . $timenow["seconds"], -2);
print($hours . " " . $minutes . " " . $seconds);
}