- var_dump: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
$start = (new DateTime(date('Y-m-d')))->modify('first day of this month');
$end = (new DateTime(date('Y-m-d', strtotime('-1 years'))))->modify('first day of this month');
$interval = DateInterval::createFromDateString('1 month');
$period = new DatePeriod($start, $interval, $end);
die(var_dump($period));
foreach ($period as $dt) {
die(var_dump($dt->format("Y-m")));
}