note 34537 added to function.time

From: Date: Wed, 30 Jul 2003 08:46:10 +0000
Subject: note 34537 added to function.time
Groups: php.notes 
Request: Send a blank email to php-notes+get-52994@lists.php.net to get a copy of this message
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"; } ---- Manual Page -- http://www.php.net/manual/en/function.time.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34537 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34537&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34537&report=yes

« previous php.notes (#52994) next »