note 34537 deleted from function.time by didou
| From: | didou@php.net | Date: | Wed, 30 Jul 2003 10:11:00 +0000 |
| Subject: | note 34537 deleted from function.time by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53000@lists.php.net to get a copy of this message | ||
Note Submitter: anders@brattoo.com
----
Due to the fact that I'm lazy I have been searching for some codesnippets that calculate the
number of days, hours minutes and second from a timestamp. I have found a few and for some strange
reason they all calculated it wrong so here's my contribution:
function timeLeft($seconds){
$days = floor($seconds/(24*60*60));
$seconds = $seconds - (24*60*60*$days);
$hours = floor($seconds/(60*60));
$seconds = $seconds - (60*60*$hours);
$minutes = floor($seconds/(60));
$seconds = $seconds - (60*$minutes);
return "$days:$hours:$minutes:$seconds";
}