From f998c4f62bd8a5f3f16cc7f37e05b24a5e0069dc Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 6 Jul 2023 15:40:53 -0600 Subject: [PATCH] Function format_hours convert seconds to an integer and use sprintf for leading zeros. --- resources/functions.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index aefd3dc6d5..084e84866c 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -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