note 53323 deleted from function.time by aidan
| From: | aidan@php.net | Date: | Sat, 08 Oct 2005 01:02:25 +0000 |
| Subject: | note 53323 deleted from function.time by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96601@lists.php.net to get a copy of this message | ||
Note Submitter: ap
----
A simple variation...send this function a number of seconds and it returns the number of days,
hours, minutes and seconds.
function seconds_to_time($seconds) {
while ($seconds >= 60) {
if ($seconds >= 86400) {
// there is more than 1 day
$days = floor($seconds / 86400);
$seconds = $seconds - ($days * 86400);
} elseif ($seconds >= 3600) {
$hours = floor($seconds / 3600);
$seconds = $seconds - ($hours * 3600);
} elseif ($seconds >= 60) {
$minutes = floor($seconds / 60);
$seconds = $seconds - ($minutes * 60);
}
}
return array('days' => $days, 'hours' => $hours, 'minutes'
=> $minutes, 'seconds' => $seconds);
}