//code functiongetMonthsInRange($startDate,$endDate){ $months=array(); while(strtotime($startDate)<=strtotime($endDate)){ $month=date('Y',strtotime($startDate))."-".date('M',strtotime($startDate)); array_push($months,$month); $startDate=date('dMY',strtotime($startDate.'+1month')); } return$months; }