I wanted to calculate the month difference between two yyyymm dates. I have this function below, however it only works if I use yyyy-mm instead.
$date1 = new DateTime('2014-01');
$date2 = new DateTime('2013-06');
$mth = mthdiff($date1, $date2);
function mthdiff($date1,$date2){
$diff = $date1->diff($date2);
return (($diff->format('%y') * 12) + $diff->format('%m'));
}