note 28306 deleted from function.mktime by sniper

From: Date: Tue, 04 Nov 2003 13:11:13 +0000
Subject: note 28306 deleted from function.mktime by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59877@lists.php.net to get a copy of this message
Note Submitter: jeff@genhex.net ---- 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.

« previous php.notes (#59877) next »