3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lastDate = new DateTime(date("Y-m-01 12:00:00")); $lastDate->sub(new DateInterval("P1M")); $generateToThisDate = new DateTime(date("Y-m-01 12:00:00")); $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"; }

preferences:
24.97 ms | 404 KiB | 5 Q