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'))."<br/>"; if ($dt->format('N') == 7) { $no++; } } echo $no;
Output for 7.4.0 - 7.4.30, 8.0.1 - 8.0.23, 8.1.0 - 8.1.10, 8.2rc1
4567123456712345673

preferences:
20.72 ms | 409 KiB | 5 Q