note 35066 deleted from function.date by cece
| From: | cece@php.net | Date: | Wed, 20 Aug 2003 13:57:05 +0000 |
| Subject: | note 35066 deleted from function.date by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54761@lists.php.net to get a copy of this message | ||
Note Submitter: imho@auspantheon.com
----
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;
}