1.比较年月日
两个时间相比较,开始时间和当前时间比较;
var startime=$("#startime").val();
var endtime=$("#endtime").val(); var nowdate=toDDMMMYYYY();
if(nowdate>startime){
alert("开始时间不能小于当前时间");
return;
}
if(startime>endtime){
alert("开始时间不能大于结束时间");
return;
}
//当前日期转为yyyy-mm-dd
function toDDMMMYYYY() {
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)
: nowDate.getMonth() + 1;
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
.getDate();
var dateStr = year +"-"+ month +"-"+ day;
return dateStr;
}