1.2023
2.2023
3.2023
4.2023
5.2023
6.2023
7.2023
8.2023
9.2023
10.2023
11.2023
12.2023
1.2024
2.2024
3.2024
4.2024
5.2024
6.2024
7.2024
8.2024
9.2024
10.2024
11.2024
12.2024
<?php
$from = DateTime::createFromFormat("m.Y", "1.2023");
$to = DateTimeImmutable::createFromFormat("m.Y", "12.2024");
$interval = DateInterval::createFromDateString('1 month');
while ($from < $to) {
echo $from->format('m.Y') . PHP_EOL;
$from = $from->add($interval);
}
echo $to->format('m.Y') . PHP_EOL;
$from = @$_GET['from'];
$to = @$_GET['to'];
$from = explode('.', $from);
$to = explode('.', $to);
//$from = isset($_GET['from']) ? $_GET['from'] : date('m.Y', mktime(0, 0, 0,
$startMonth = $from[0];
$endMonth = $to[0];
$startYear = $from[1];
$endYear = $to[1];
$year = $startYear;
$month = $startMonth;
for ($i = $startMonth; $i <= ($endMonth * ($endYear - ($startYear -1))); $i++) {
if ($month > 12) {
$year++;
$month = 1;
}
echo "[$month, $year]<br>";
$month++;
}