Get months from two date range in PHP

Here is the code you are looking for:

function get_months($date1, $date2) {  
   $time1  = strtotime($date1);  
   $time2  = strtotime($date2);  
   $my     = date('n-Y', $time2);  
   $mesi = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 
    
   //$months = array(date('F', $time1));  
   $months = array();  
   $f      = '';  

   while($time1 < $time2) {  
      if(date('n-Y', $time1) != $f) {  
         $f = date('n-Y', $time1);  
         if(date('n-Y', $time1) != $my && ($time1 < $time2)) { 
             $str_mese=$mesi[(date('n', $time1)-1)]; 
            $months[] = $str_mese." ".date('Y', $time1);  
         } 
      }  
      $time1 = strtotime((date('Y-n-d', $time1).' +15days'));  
   }  

   $str_mese=$mesi[(date('n', $time2)-1)]; 
   $months[] = $str_mese." ".date('Y', $time2);  
   return $months;  
} 

print_r(get_months('2013-01-01', '2014-03-30'));