<script type="text/javascript">
//比较两个时间是否大于一个月,例如20170215--到20170315 是一个月,到20170316是大于一个月
function getD(sDate, endDate) {
var sDate = new Date(sDate);
var eDate = new Date(endDate);
if (eDate.getFullYear() - sDate.getFullYear() > 1) {//先比较年
return true;
} else if (eDate.getMonth() - sDate.getMonth() > 1) {//再比较月
return true;
} else if (eDate.getMonth() - sDate.getMonth() == 1) {
if (eDate.getDate() - sDate.getDate() >= 1) {
return true;
}
}
else if (eDate.getFullYear() - sDate.getFullYear() == 1) {
if (eDate.getMonth()+12 - sDate.getMonth() > 1) {
return true;
}
else if (eDate.getDate() - sDate.getDate() >= 1) {
return true;
}
}
return false;
}
var c = getD("2017-12-25", "2018-02-06");
alert(c)
</script>