For example, I have got the following code:
$time1 = 14:02:21;
$time2 = 12:04:48;
$time3 = 08:19:17;
$addtime = $time1 + $time2 + $time3;
echo $addtime;
Which would return 34:26:26
I am trying to do this inside of a while loop:
Before while loop:
$on_duty_time = '';
Inside of While Loop:
$on_duty_time += strtotime($row2['driving_timer']);
After the While Loop:
$on_duty_time -= strtotime('00:00:00');
$time = date('H:i:s', $on_duty_time);
echo $time;
This code worked when I had two timestamps only, which were 00:35:40 and 00:00:21 (being called in by the variable $row2['driving_timer']
), which gave me the end result of 00:36:01.
But now one of my loops has the timestamp: 00:01:36, but it is returning 17:01:36 when I try to put it through my while loop code.
Any ideas on why this is happening?
Or perhaps, does anyone know of a better way to add these timestamps together whilst using a while loop?