<?php $start = new \DateTime('first day of this month'); $end = (new \DateTime('first day of this month'))->modify('+18 months'); $interval = new \DateInterval('P1M'); $period = new \DatePeriod($start, $interval, $end); foreach ($period as $month) { $lastDayOfMonth = $month->format('t'); $day = (date('d') > $lastDayOfMonth) ? $lastDayOfMonth : date('d'); echo $month->format("n | Y | Y-m-{$day}"); echo "\n"; }
You have javascript disabled. You will not be able to edit any code.