Gets month difference between the two in January

   / * * 
     * Get all dates between two months 
     * @param string $ date1 - the starting date of default 1970-01-01 
     * @param String $ that represented by DATE2 - Deadline default 1970-02-01 
     * @return Array 
     * / 
    public  function getMonthNum ( String  $ date1 = '1970-01-01', String  $ DATE2 = '1970-02-01'): Array 
    { 
        $ TIME1 = strtotime ( $ date1 ); // automatically division 00:00:00 s 
        $ TIME2 = strtotime ( $ DATE2 );
         IF ( $ TIME2 < $ TIME1 ) {
            return []; 
        } 
        $ month The = Array ();
         $ split_date1 = the explode ( '-', $ date1 );
         $ month The [] = $ split_date1 . [0] .'- ' $ split_date1 [. 1]; // Init 
        the while (( $ TIME1 = strtotime ( '+ 1'd month The', $ TIME1 )) <= $ TIME2 ) {
             $ month The [] = DATE ( 'the Y-m', $ TIME1 ); // obtain month increments; 
        }
         return  $ month The  ;
    }

 

Guess you like

Origin www.cnblogs.com/studyandstudy/p/11345228.html