function doDateCompare(strDate){
var ereg = /^(\d{1,4})(-|\/)(\d{1,2})(-|\/)(\d{1,2})$/;
var checkResult = strDate.match(ereg);
if (checkResult == null) {
return false;
}
var year = strDate.substring(0,4);
var month = strDate.substring(5,7);
var day = strDate.substring(8,10);
var currentDay = new Date(year, month -1, day);
var checkDay = currentDay.format("yyyyMMdd");
if(currentDay.getFullYear() == year && (currentDay.getMonth()+1) == month && currentDay.getDate() == day){
var nowDay = new Date().format("yyyyMMdd");
if(checkDay <= nowDay ){
return "Before";
}else{
return "After";
}
}else{
return false;
}
}
JS验证日期 比较日期
最新推荐文章于 2022-08-09 20:59:30 发布