3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period = new \DatePeriod( (new Chronos("last day of -$months month"))->setTime(23, 59, 59, 999), new \DateInterval('P1M'), new Chronos() ); foreach ($period as $until) { var_dump($until); }

preferences:
52.13 ms | 402 KiB | 5 Q