3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('2019-01-01'); $end = new DateTime('2019-02-27'); $interval = new DateInterval('P1D'); $days = 19; while ($start < $end) { echo $start->format('Y-m-d') . ' => '; for ($i = 0; $i < $days; ) { $start->add($interval); $day_of_week = $start->format('N'); if ($day_of_week == 6 || $day_of_week == 7) continue; $i++; } echo min($start, $end)->format('Y-m-d') . "\n"; $start->add($interval); }

preferences:
30.59 ms | 404 KiB | 5 Q