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

// 判断时间是否超过了16:30
    // true:    已超时
    // false:   未超时
    function timeCompare() {
        var now = new Date();
        var nowTime = now.getTime();
        var year = now.getFullYear();
        var month = now.getMonth() + 1;//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;
        }
    }

 

posted @ 2018-12-05 09:30  anderson_1996  阅读(1154)  评论(0编辑  收藏  举报