Need to convert seconds to DD:HH:MM:SS

From: Date: Fri, 19 Sep 2003 21:51:41 +0000
Subject: Need to convert seconds to DD:HH:MM:SS
Groups: php.general 
Request: Send a blank email to php-general+get-163236@lists.php.net to get a copy of this message
So clearly I'm being stupid and this seemingly basic math is beyond my abilities at the moment. I've tried various things, but can't seem to figure out how to get the number of days integrated in here for $hh that are > 24. I've googled for code fragments and can't find one. All seem to deal with the Epoch and dates. I just want to take a number of seconds and convert it to days:hours:minutes:seconds... This function works for what it does, can someone embelish it to handle days too? function convertToHHMMSS($seconds) { $hoursPerDay = 24; $SecondsPerHour = 3600; $SecondsPerMinute = 60; $MinutesPerHour = 60; $hh = intval($seconds / $SecondsPerHour); $mm = intval($seconds / $SecondsPerMinute) % $MinutesPerHour; $ss = $seconds % $SecondsPerMinute; return $hh."h:".$mm."m:".$ss."s"; } Daevid Vincent http://daevid.com

« previous php.general (#163236) next »