js判断时间是否超过了16:30

时间:2021-08-22 13:20:30
// 判断时间是否超过了16:30
// true: 已超时
// false: 未超时
function timeCompare() {
var now = new Date();
var nowTime = now.getTime();
var year = now.getFullYear();
var month = now.getMonth() + ;//js从0开始取
var date = now.getDate();
var deadlineStr = year + "/" + month + "/" + date + " " + "16:30:00";
var deadline = Date.parse(deadlineStr);
if (nowTime > deadline) {
return true;
} else {
return false;
}
}