- date: documentation ( source)
- strtotime: documentation ( source)
<?php
//echo date('Y-m-d', strtotime('first day of last month'));
//$date = new DateTime('');
//$date->modify('first day of month');
$date = new DateTime(date('Y-m-d', strtotime('first day of last month')));
$i = new DateInterval('P1M');
$end = new DateTime('-1 year');
while ($date >= $end) {
echo $date->format('Y F') . PHP_EOL;
$date = $date->sub($i);
}