0

calculate number of month between two dates

Count month -php

19th Dec 2018, 11:22 AM
Erick Raphael
Erick Raphael - avatar
2 ответов
+ 7
Something like this: $date1 = '2000-01-25'; $date2 = '2010-02-20'; $ts1 =strtotime($date1); $ts2 = strtotime($date2); $year1 = date('Y', $ts1); $year2 = date('Y', $ts2); $month1 = date('m', $ts1); $month2 = date('m', $ts2); $diff = (($year2 - $year1) * 12) + ($month2 - $month1) ; Maybe you'll have to include days as well. https://stackoverflow.com/questions/13416894/calculate-the-number-of-months-between-two-dates-in-php
19th Dec 2018, 11:35 AM
dρlυѕρlυѕ
dρlυѕρlυѕ - avatar
+ 6
Can you show your attempt?
19th Dec 2018, 11:30 AM
GiveAway
GiveAway - avatar