//返回两个日期相差的月数
function MonthsBetw(date1, date2) {
//用-分成数组
date1 = date1.split("-");
date2 = date2.split("-");
//获取年,月数
var year1 = parseInt(date1[0]),
month1 = parseInt(date1[1]),
year2 = parseInt(date2[0]),
month2 = parseInt(date2[1]),
//通过年,月差计算月份差
months = (year2 - year1) * 12 + (month2 - month1) + 1;
return months;
}

05-06 03:31