PCHomepage
Programmer
I'm working on a simple function that I expected would give me HH:MM:SS.xxxxxx and it is giving the correct result in general but it is rounding off the seconds rather than showing their decimal fraction where it exists. This is a video time conversion and I thought there would be a remainder to need conversion to frames but it seems to not have any remainder. It's late and my brain is fried so maybe there will always be full seconds with no "excess" but can someone confirm or tell me what I did wrong?
Thank you.
Thank you.
Code:
function tsdate($seconds) {
$hours = floor($seconds/3600);
$remainder_1 = ($seconds % 3600);
$minutes = floor($remainder_1 / 60);
$seconds = ($remainder_1 % 60);
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;
}