查看当前时间是否在设定日期之前

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>判断当前是时间是否在设定时间之前</title>
</head>
<body>
<script type="text/javascript">
(function(){
var currentDate = new Date();
var year = currentDate.getFullYear();//
var month = currentDate.getMonth()+1;//
var day = currentDate.getDate();//
var hour = currentDate.getHours();//
var minute = currentDate.getMinutes();//
var second = currentDate.getSeconds();//
var millisecond = currentDate.getMilliseconds();//毫秒
console.log("currentDate:"+currentDate);
console.log("年:"+year+"
月:"+month+"
日:"+day+"
时:"+hour+"
分:"+minute+"
秒:"+second+"
毫秒:"+millisecond);
console.log(""+year+month+day+hour);
if(year>2018){
expired()
}else if(month>9){
expired()
}else if(month==9&&day>24){
expired()
}
function expired(){
console.log('该时间在设定时间之后,已过期');
return false;
}
})()
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/llllpzyy/p/9688792.html