我目前有以下脚本:

<script>
if(new Date().getHours() > 17 || (new Date().getHours() == 17 &&
new Date().getMinutes()== 0 && new Date().getSeconds() == 0) &&
(new Date().getHours() < 21 && new Date().getMinutes() < 30
&& new Date().getSeconds() == 0)){
        //do nothing.
    } else {
    $(document).ready(function() {
        $(".inline").colorbox({inline:true, open:true, width:"50%"});
        });
    }




所以从根本上说,如果:
如果时间是17:00到21:30,则什么也不做,否则显示此框。但是发生的情况是,盒子在18:00左右停止工作,并在午夜再次开始工作。有人看到这里有什么问题吗?

最佳答案

var d = new Date();

if ( d.getHours() < 17 ||
     d.getHours() > 21 ||
    (d.getHours() == 21 && d.getMinutes() >= 30)) {

        $(document).ready(function() {
            $(".inline").colorbox({inline:true, open:true, width:"50%"});
        });
}

07-24 09:52
查看更多