I'm looking for a function that takes a numeric value in seconds and return it in a 00:00:00 format. For example, it takes 90 and returns 00:01:30 Can anyone helpme here?
Here you go: <?php function timeformat($sec){ if($sec > 59){ $min = $sec/60; $min = floor($min); $sec = $sec%60; } if($min > 59){ $hour = $min/60; $hour = floor($hour); $min = $min - $hour * 60; } else { $hour = "00"; } if(strlen($sec) == "1"){ $sec = "0".$sec; } if(strlen($min) == "1"){ $min = "0".$min; } if(strlen($hour) == "1"){ $hour = "0".$hour; } return $hour . ":" . $min . ":" . $sec; } echo timeformat(90); ?> PHP: There's probably an easier way to do it, but that works fine.