Your problem is precisely in the gmdate function, because it will format a date from a timestamp ( Unix Epoch ). As in the example below:
gmdate("d/m/Y h:i:s", '1000000'); // 12/01/1970 01:46:40
You could add / divide / multiply the time you have already calculated, to reach the end time. However, I do not really like this approach, because it leaves out what PHP has internally already implemented.
In this case, PHP has a specific class to work with time / date ranges, which is the class DateInterval . However, it is not so trivial to work with it for your specific case, because, natively, you can not add one DateInterval to another.
Another detail is the format that the DateInterval needs to be created, which is different from the traditional date format (so to speak).
On the other hand, you can use the DateTime class together, which helps us to create a DateInterval without changing the format coming from the database.
//é necessária uma data base (00:00:00) - $baseDate
//e uma data para adicionar/somar os tempos vindos do SGBD - $date
$baseDate = clone $date = \DateTime::createFromFormat('H:i:s' , '00:00:00');
//dados vindo do banco de dados
$array = [
'04:30',
'05:30',
'04:23',
'02:35',
'01:50',
'03:25',
'03:40',
'02:30'
];
//percorre cada valor do array
foreach($array as $time)
{
//cria-se o date time com o tempo informado
$dateTime = \DateTime::createFromFormat('H:i' , $time);
//realiza o diff com a $baseDate para criar o DateInterval
$diff = $baseDate->diff($dateTime);
//adiciona o diff ao DateTime que somará o tempo
$date->add($diff);
}
//realiza o último diff entre o DateTime de soma e a base date
$interval = $baseDate->diff($date);
//DateInterval mantêm em dias (%a) tudo que for acima de 24 horas.
$hours = $interval->format('%H') + ($interval->format('%a') * 24);
//exibe o tempo
echo $hours.$interval->format(':%I'); // Saída: 28:23
The code has gotten a bit lengthy for the explanation, however, you can use objects that can be reused for display and other calculations when needed.