Skip to content

Instantly share code, notes, and snippets.

@thejwalker thejwalker/HH:MM:SS
Created Sep 19, 2011

Embed
What would you like to do?
Convert Seconds to HH:MM:SS
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
You can’t perform that action at this time.