How to get current monthly interval from given date till today in PHP? -
for example starting date 5th january 2017 , today 7th april 2017. 5th jan 5th feb interval 1, 5th feb 5th march interval 2, 5th march 5th april interval 3. 5th april till 5th may interval 4.
so if today 7th april result should return interval 4.
function currrent_monthly_interval($from_date) { $interval = date_diff(date_create($from_date), date_create(date('y-m-d'))); return intval($interval->format('%m')) + 1 ; }
Comments
Post a Comment