Function format_hours convert seconds to an integer and use sprintf for leading zeros.

This commit is contained in:
FusionPBX 2023-07-06 15:40:53 -06:00 committed by GitHub
parent 8c8ef2c309
commit f998c4f62b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -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