note 28306 added to function.mktime

From: Date: Wed, 08 Jan 2003 21:07:00 +0000
Subject: note 28306 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-41859@lists.php.net to get a copy of this message
After unsuccessfully searching for code to convert seconds to days hours minutes seconds, I came up with the following 4 lines of code that does it for me: $seconds = 90061; // any number of seconds $edays = floor($seconds / 86400); // get days $ehours = floor(($seconds % 86400) / (3600)); // get hours $emins = floor((($seconds % 86400) % 3600) / 60); // get mins $esecs = floor((($seconds % 86400) % 3600) % 60); // get secs print "Total Seconds: $seconds"; print "Days: $edays - Hours: $ehours - Minutes: $emins - Seconds: $esecs"; This would give you: Total Seconds: 90061 Days: 1 - Hours: 1 - Minutes: 1 - Seconds 1 I hope this helps anyone who needs this functionality. Cheers, Jeff. -- http://www.php.net/manual/en/function.mktime.php http://master.php.net/manage/user-notes.php?action=edit+28306 http://master.php.net/manage/user-notes.php?action=delete+28306 http://master.php.net/manage/user-notes.php?action=reject+28306

« previous php.notes (#41859) next »