// Created on savesnippets.com · https://savesnippets.com/bQRvMOHxOzNnDh $end) [$start, $end] = [$end, $start]; $hSet = array_fill_keys(array_map(fn($d) => $d->format('Y-m-d'), $holidays), true); $count = 0; for ($d = clone $start; $d <= $end; $d = $d->modify('+1 day')) { $dow = (int)$d->format('N'); // 1=Mon … 7=Sun if ($dow >= 6) continue; if (isset($hSet[$d->format('Y-m-d')])) continue; $count++; } return $count; } $start = new DateTime('2025-01-01'); $end = new DateTime('2025-01-31'); $holidays = [new DateTime('2025-01-20')]; // MLK Day echo businessDays($start, $end, $holidays); // 22