I am trying to store time into variable which type is string, following is script
$time = '00:00:00';
foreach($GameLog->gamelogs->toArray() as $Data){
$base = strtotime('00:00:00');
$seconds = (strtotime($time) - $base) + (strtotime($Data['pivot']['time_spent']) - $base);
}
$hours = floor($seconds / 3600);
$minutes = floor($seconds / 60) % 60;
$seconds = $seconds % 60;
$ResultArray['time'] = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
where is $Data['pivot']['time_spent'] has different times like
00:05:30
00:03:25
00:12:39
By above loop method I am unable to store the time, because it is returning wrong result. how can i fix the issue?