js实现月份比较
程序员文章站
2023-12-24 17:42:45
...
/**
* 月份比较
* @param startDate
* @param endStart
* @returns
*/
function getIntervalMonth(startDateStr,endDateStr){
if(startDateStr == null || endDateStr == null){
return 3;
}
var startDate = new Date(startDateStr);
var endDate = new Date(endDateStr);
var startMonth = startDate.getMonth();
var endMonth = endDate.getMonth();
var intervalMonth = (endDate.getFullYear()*12+endMonth) - (startDate.getFullYear()*12+startMonth);
return intervalMonth;
}