我有一组 intime 和 outtime,我想计算 intime 和 outtime 之间的持续时间并添加所有持续时间以获得总持续时间。
例子:
Array
(
[1] => Array
(
['intime'] => 1342086993
['outime'] => 1342087585
)
[3] => Array
(
['intime'] => 1342087669
['outtime] => 1342096165
)
[5] => Array
(
['intime'] => 1342096339
['outime'] => 1342096345
)
)
$total_duration = 0;
foreach($logArray as $log)
{
$duration = $log['outime'] - $log['intime'];
$total_duration += $duration;
}
$duration_hrs = $total_duration/3600;
echo 'Time spend in hrs :'.$duration_hrs;
但这并没有给我适当的持续时间。有没有其他方法可以做到这一点。