Skip to content

Instantly share code, notes, and snippets.

@thejwalker
Created September 19, 2011 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejwalker/1225841 to your computer and use it in GitHub Desktop.
Save thejwalker/1225841 to your computer and use it in GitHub Desktop.
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