php获取两个日期相差多少个月份
function getMonthDiffNum($startDate, $endDate)
{
$startDate = strtotime($startDate);
$endDate = strtotime($endDate);
$Y = date('Y', $endDate) - date('Y', $startDate);
$M = date('m', $endDate) - date('m', $startDate);
return $cha = abs($Y * 12 + $M);
}
$num=getMonthDiffNum('2018-12-11','2019-11-01');
echo $num;