任何人都可以帮助我获得$total_h
以下循环中的总和或总数吗?我只需要在循环结束后显示 $total_h 的总和,这样我就知道我工作了多少小时。
<?php
$get_time = mysql_query("select * from tbl_timekeep where emp_id =
'OJT0125' order by date desc");
while ($fect_time = mysql_fetch_array($get_time))
{
if ($fect_time[3] == '----' || $fect_time[3] == 'No Out')
{
$out = '17:00:00';
}
else
{
$out = $fect_time[3];
}
$from = new DateTime($fect_time[2]);
$to = new DateTime($out);
$total_h = $from->diff($to)->format('%h.%i');``
echo $fect_time[2].'to'.$fect_time[3]." = [ $total_h ]<br>";
}
?>