Можно как-то так:
$schedule = [
'weekdays' => [
1 => [[0, 24]],
2 => [[0, 24]],
...
7 => [[0, 6], [8, 24]]
],
'dates' => [
'2020-12-31' => [[0, 6], [8, 17]],
'2021-01-01' => [[0, 0]],
'2020-01-02' => [[10, 23]],
...
]
];
function isWorkTime($schedule) {
$date = date('Y-m-d');
$weekday = intval(date('N'));
$hour = intval(date('H'));
$daySchedule = $schedule['weekdays'][$weekday];
if (array_key_exists($date, $schedule['dates']]) {
$daySchedule = $schedule['dates'][$date];
}
foreach ($daySchedule as $workTime) {
if ($hour >= $workTime[0] && $hour < $workTime[1]) {
return true;
}
}
return false;
}