Created
September 19, 2011 01:53
-
-
Save thejwalker/1225841 to your computer and use it in GitHub Desktop.
Convert Seconds to HH:MM:SS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function seconds($seconds) { | |
// CONVERT TO HH:MM:SS | |
$hours = floor($seconds/3600); | |
$remainder_1 = ($seconds % 3600); | |
$minutes = floor($remainder_1 / 60); | |
$seconds = ($remainder_1 % 60); | |
// PREP THE VALUES | |
if(strlen($hours) == 1) { | |
$hours = "0".$hours; | |
} | |
if(strlen($minutes) == 1) { | |
$minutes = "0".$minutes; | |
} | |
if(strlen($seconds) == 1) { | |
$seconds = "0".$seconds; | |
} | |
return $hours.":".$minutes.":".$seconds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment