3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime('now'); $end = new DateTime('-1 year'); function getDates($start, $end) { $interval = new DateInterval('P1M'); $daterange = new DatePeriod($end,$interval,$start); $range = []; foreach($daterange as $date){ $range[] = $date->format("m-Y"); } return $range; } getDates($start,$end);
based on M87gM
Output for 5.6.0 - 7.3.0rc4