我正在尝试将时间存储到类型为字符串的变量中,下面是脚本
$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);
$Data['pivot']['time_spent']
在哪里与
00:05:30
00:03:25
00:12:39
通过上述循环方法,我无法存储时间,因为它返回了错误的结果。我该如何解决该问题?