Log 3978
19/09/2024 2024-09-19 11:24$hours_worked = 8;
$start_time = “09:00”;
$end_time = “17:00”;
$break_start = “12:30”;
$break_end = “13:00”;
// Calculate total working hours excluding break time
$total_hours_excluding_break = (strtotime($end_time) – strtotime($start_time)) / 3600 – (strtotime($break_end) – strtotime($break_start)) / 3600;
// Check if any of the times crosses midnight for the next day calculation
if (strtotime($end_time) < strtotime("01:00")) {
$total_hours_excluding_break -= (strtotime("00:00") – strtotime("24:00")) / 3600;
}
return $total_hours_excluding_break;