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
|
//format seconds into hh:mm:ss
|
||||||
function format_hours($seconds) {
|
function format_hours($seconds) {
|
||||||
|
$seconds = (int)$seconds; //convert seconds to an integer
|
||||||
$hours = floor($seconds / 3600);
|
$hours = floor($seconds / 3600);
|
||||||
$minutes = floor(floor($seconds / 60) % 60);
|
$minutes = floor(floor($seconds / 60) % 60);
|
||||||
$seconds = $seconds % 60;
|
$seconds = $seconds % 60;
|
||||||
if (strlen($minutes) == 1) { $minutes = '0'.$minutes; }
|
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
|
||||||
if (strlen($seconds) == 1) { $seconds = '0'.$seconds; }
|
|
||||||
return "$hours:$minutes:$seconds";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//browser detection without browscap.ini dependency
|
//browser detection without browscap.ini dependency
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue