3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start_date = new DateTime('2019-01-01'); $end_date = new DateTime('2019-12-31'); $dt = clone $start_date; $dt->modify('first day of this month')->modify('+2 Sundays'); while ($dt <= $end_date) { if ($dt >= $start_date) $result[] = $dt->format('d.m.Y'); $dt->modify('first day of next month')->modify('+2 Sundays'); } print_r ($result);

preferences:
83.1 ms | 1453 KiB | 6 Q