/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function sec2hms ($sec, $padHours = false) {
$hms = "";
// there are 3600 seconds in an hour, so if we
// divide total seconds by 3600 and throw away
// the remainder, we've got the number of hours
// add to $hms, with a leading 0 if asked for
$hms .= ($padHours)
: $hours. ':';
// dividing the total seconds by 60 will give us
// the number of minutes, but we're interested in
// minutes past the hour: to get that, we need to
// divide by 60 again and keep the remainder
// then add to $hms (with a leading 0 if needed)
// seconds are simple - just divide the total
// seconds by 60 and keep the remainder
// add to $hms, again with a leading 0 if needed
return $hms;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                