2
To find the difference between two dates, the date_diff().
$datetime1 = date_create('2016-10-11');
$datetime2 = date_create('2018-10-11');
$interval = date_diff($datetime1, $datetime2);
return $interval->m; // months
The code works perfectly as long as the difference between dates is less than 12. If greater or equal, $interval->m
returns 0
, but I need it to return the number of months in any case.
Does anyone know any workaround?