note 35066 added to function.date
| From: | imho at auspantheon dot com | Date: | Mon, 18 Aug 2003 14:27:40 +0000 |
| Subject: | note 35066 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54586@lists.php.net to get a copy of this message | ||
My implementation of the duration function in mIRC.
# Time between two timestamps in human readable format
function duration ($start, $end = null)
{
if ($end === null)
$end = time();
$seconds = $end - $start;
$days = round($seconds / 86400); // One day has 86400 seconds
$seconds = $seconds % 86400;
$hours = round($seconds / 3600); // One hour has 3600 seconds
$seconds = $seconds % 3600;
$minutes = round($seconds / 60); // One minute has 60 seconds
$seconds = $seconds % 60;
$duration = "$days days, $hours hours, $minutes minutes, $seconds seconds";
return $duration;
}
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35066
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35066&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35066&report=yes