欢迎来到HELLO素材网! 南京网站制作选择顺炫科技
丰富的DIV CSS模版、JS,jQuery特效免费提供下载
当前位置:主页 > 建站教程 > JS教程 >

JavaScript比较能否在某工夫段内

发表于2019-04-23 18:01| 次阅读| 来源网络整理| 作者session

摘要:JavaScript比较能否在某工夫段内
JavaScript比较能否在某工夫段内

      function checkTime(stime, etime) {

              //末尾工夫

              var arrs = stime.split("-");

              var startTime = new Date(arrs[0], arrs[1], arrs[2]);

              var startTimes = startTime.getTime();

              //完结工夫

              var arre = etime.split("-");

              var endTime = new Date(arre[0], arre[1], arre[2]);

              var endTimes = endTime.getTime();

              //以后工夫

              var thisDate = new Date();

              var thisDates = thisDate.getFullYear() + "-0" + (thisDate.getMonth() + 1) + "-" + thisDate.getDate();

              var arrn = thisDates.split("-");

              var nowTime = new Date(arrn[0], arrn[1], arrn[2]);

              var nowTimes = nowTime.getTime();

              if (nowTimes < startTimes || nowTimes > endTimes) {

                  return false;

              }

              return true;

          }