3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = (new DateTime('2014-01-01'))->modify('first day of this month'); $end = (new DateTime('2015-03-04'))->modify('first day of this month'); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($start, $interval, $end); $months = array(); foreach ($period as $dt) { $months[] = $dt->format("F Y"); } print_r($months);

preferences:
28.09 ms | 404 KiB | 5 Q