3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new \DateTime('first day of this month'); $end = (new \DateTime('first day of this month'))->modify('+18 months'); $interval = new \DateInterval('P1M'); $period = new \DatePeriod($start, $interval, $end); foreach ($period as $month) { $lastDayOfMonth = $month->format('t'); $day = (date('d') > $lastDayOfMonth) ? $lastDayOfMonth : date('d'); echo $month->format("n | Y | Y-m-{$day}"); echo "\n"; }
Output for 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
8 | 2018 | 2018-08-28 9 | 2018 | 2018-09-28 10 | 2018 | 2018-10-28 11 | 2018 | 2018-11-28 12 | 2018 | 2018-12-28 1 | 2019 | 2019-01-28 2 | 2019 | 2019-02-28 3 | 2019 | 2019-03-28 4 | 2019 | 2019-04-28 5 | 2019 | 2019-05-28 6 | 2019 | 2019-06-28 7 | 2019 | 2019-07-28 8 | 2019 | 2019-08-28 9 | 2019 | 2019-09-28 10 | 2019 | 2019-10-28 11 | 2019 | 2019-11-28 12 | 2019 | 2019-12-28 1 | 2020 | 2020-01-28 2 | 2020 | 2020-02-28
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28
8 | 2018 | 2018-08-28 9 | 2018 | 2018-09-28 10 | 2018 | 2018-10-28 11 | 2018 | 2018-11-28 12 | 2018 | 2018-12-28 1 | 2019 | 2019-01-28 2 | 2019 | 2019-02-28 3 | 2019 | 2019-03-28 4 | 2019 | 2019-04-28 5 | 2019 | 2019-05-28 6 | 2019 | 2019-06-28 7 | 2019 | 2019-07-28 8 | 2019 | 2019-08-28 9 | 2019 | 2019-09-28 10 | 2019 | 2019-10-28 11 | 2019 | 2019-11-28 12 | 2019 | 2019-12-28 1 | 2020 | 2020-01-28

preferences:
204.82 ms | 411 KiB | 5 Q