I'm developing a system in PHP where I need to at some point get the total time of an audio file. This time is saved in the database in seconds and also in the time format.
The problem is that when you format these times through the seconds saved in the database, this works normally, but only if the file has less than 24 hours.
Example:
$date = new DateTime('@0'); // "zeramos" a data
$tempo_1 = 10 * 3600; // 10 horas
$tempo_2 = 18 * 3600; // 18 horas
$tempo_3 = 28 * 3600; // 28 horas
echo $date->setTime(0, 0, $tempo_1)->format('H:i:s'); // 10:00:00
echo $date->setTime(0, 0, $tempo_2)->format('H:i:s'); // 18:00:00
echo $date->setTime(0, 0, $tempo_3)->format('H:i:s'); // 04:00:00
In the last example, the desired result was 28:00:00
. However, because it is a class that works with dates, it returns 04:00:00
, on account of 24
equals 1 day.
How could I do to get this formatted time in hours, even if it exceeds 24 hours?