具有以下值:
$a[0] = "4:00:00 am"
$b[0] = "8:00:00 am"
$c[0] = "9:00:00 am"
$d[0] = "1:22:00 pm"
为什么第二个 if 语句会导致将 -8 值写入数据库?第一个 if 语句产生适当的 4 小时值,但不是第二个。是因为上午/下午的变化还是什么?
if (!$a[0]=="" AND !$b[0]=="") {
$start = explode(':', $a[0]);
$end = explode(':', $b[0]);
$total_hours = $end[0] - $start[0] - ($end[1] < $start[1]);
mysqli_query($con,"UPDATE timeclock SET daily_hours='$total_hours' WHERE idex='$data[idex]' AND date='$date' AND status='slunch'");
}
if (!$c[0]=="" AND !$d[0]=="") {
$start = explode(':', $c[0]);
$end = explode(':', $d[0]);
$total_hours = $end[0] - $start[0] - ($end[1] < $start[1]);
mysqli_query($con,"UPDATE timeclock SET daily_hours='$total_hours' WHERE idex='$data[idex]' AND date='$date' AND status='ework'");
}