- var_dump: documentation ( source)
<?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);
}