3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lastDate = new DateTime(); $lastDate->sub(new DateInterval("P1M")); $generateToThisDate = new DateTime(); $generateToThisDate->add(new DateInterval("P20M")); while ($lastDate < $generateToThisDate) { $lastDate->add(new DateInterval("P1M")); echo $lastDate->format('Y-m-d') . " - " . $lastDate->format('Y-m-t') . "\n"; }
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 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.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
2016-05-30 - 2016-05-31 2016-06-30 - 2016-06-30 2016-07-30 - 2016-07-31 2016-08-30 - 2016-08-31 2016-09-30 - 2016-09-30 2016-10-30 - 2016-10-31 2016-11-30 - 2016-11-30 2016-12-30 - 2016-12-31 2017-01-30 - 2017-01-31 2017-03-02 - 2017-03-31 2017-04-02 - 2017-04-30 2017-05-02 - 2017-05-31 2017-06-02 - 2017-06-30 2017-07-02 - 2017-07-31 2017-08-02 - 2017-08-31 2017-09-02 - 2017-09-30 2017-10-02 - 2017-10-31 2017-11-02 - 2017-11-30 2017-12-02 - 2017-12-31 2018-01-02 - 2018-01-31 2018-02-02 - 2018-02-28

preferences:
183.19 ms | 405 KiB | 332 Q