I am doing a comparasion between two dates and trying to get the year and month difference between those two dates (not the day itself).
$d1 = strtotime("2012-12");
$d2 = strtotime("2014-03");
$min_date = min($d1, $d2);
$max_date = max($d1, $d2);
$i = 0;
while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
$i++;
}
echo $i;
This outputs 15 months but how would i go about converting that into months and years?
Or if there is a better way of handling this - would love to know