Function format_hours convert seconds to an integer and use sprintf for leading zeros.
This commit is contained in:
parent
8c8ef2c309
commit
f998c4f62b
|
|
@ -832,12 +832,11 @@ function format_string($format, $data) {
|
|||
|
||||
//format seconds into hh:mm:ss
|
||||
function format_hours($seconds) {
|
||||
$seconds = (int)$seconds; //convert seconds to an integer
|
||||
$hours = floor($seconds / 3600);
|
||||
$minutes = floor(floor($seconds / 60) % 60);
|
||||
$seconds = $seconds % 60;
|
||||
if (strlen($minutes) == 1) { $minutes = '0'.$minutes; }
|
||||
if (strlen($seconds) == 1) { $seconds = '0'.$seconds; }
|
||||
return "$hours:$minutes:$seconds";
|
||||
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
|
||||
}
|
||||
|
||||
//browser detection without browscap.ini dependency
|
||||
|
|
|
|||
Loading…
Reference in New Issue