note 35398 added to ref.datetime
| From: | dkan at netscreen dot com | Date: | Fri, 29 Aug 2003 18:40:46 +0000 |
| Subject: | note 35398 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55318@lists.php.net to get a copy of this message | ||
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);
}
----
Manual Page -- http://www.php.net/manual/en/ref.datetime.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35398
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35398&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35398&report=yes