with the following values:
$a[0] = "4:00:00 am"
$b[0] = "8:00:00 am"
$c[0] = "9:00:00 am"
$d[0] = "1:22:00 pm"
why would the second if statement result in a -8 value being written to database? The first if statement results in the appropriate 4 hours value, but not the second. Is it because of the am/pm change or something?
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'");
}