具有以下值:PHP計算產生負數?
$a[0] = "4:00:00 am"
$b[0] = "8:00:00 am"
$c[0] = "9:00:00 am"
$d[0] = "1:22:00 pm"
爲什麼會如果在一個-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'");
}
得到它,應該抓住這一點。謝謝 – DMSJax