- date_default_timezone_set: documentation ( source)
- ini_set: documentation ( source)
- error_reporting: documentation ( source)
<?php
error_reporting(-1);
ini_set('display_errors', 1);
date_default_timezone_set('UTC');
//to be sure that DateInterval will work as intended
$fist_day_of_the_month = (new DateTime)->format('Y-m-01');
$range = new DatePeriod(
new DateTime($fist_day_of_the_month), //begin
new DateInterval('P1M'), //interval
new DateTime($fist_day_of_the_month.' +24 month') //end
);
foreach ($range as $date) {
echo $date->format('Y-m-d'), PHP_EOL;
}