3v4l.org

run code in 300+ PHP versions simultaneously
<?php $no = 0; $start = new DateTime('2022-09-01'); $end = new DateTime('2022-09-19'); $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($start, $interval, $end); foreach ($period as $dt) { print_r($dt->format('N')."--"); if ($dt->format('N') == 7) { $no++; } } echo $no;

preferences:
44.75 ms | 402 KiB | 5 Q