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;
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
4567123456712345673

preferences:
124.06 ms | 402 KiB | 120 Q