zoukankan      html  css  js  c++  java
  • js 判断所选时间(或者当前时间)是否在某一时间段用于不同时间段显示不同的客服qq

    //qq交谈
    var nowtimes= new Date();
    var starttimes="16:30";
    var endtimes="23:59";
    var timestrings=nowtimes.getHours()+":"+nowtimes.getMinutes();
     function qqchats1(){
         if(!time_range (starttimes,endtimes,timestrings)){
           var list = new Array("2885794580","3001017451");   
         }
         else
         {
            var list = new Array("2885794572","2885794571");         
         }
            var i = fRandomBy(0,1);
            window.location.href = "tencent://message/?uin="+list[i]+"&Site=&menu=yes";
    }function fRandomBy(under, over){ 
       switch(arguments.length){ 
         case 1: return parseInt(Math.random()*under+1); 
         case 2: return parseInt(Math.random()*(over-under+1) + under); 
         default: return 0; 
       }
    }   
    
    var time_range = function (beginTime, endTime, nowTime) {
          var strb = beginTime.split (":");
          if (strb.length != 2) {
              return false;
          }
      
          var stre = endTime.split (":");
          if (stre.length != 2) {
              return false;
         }
     
         var strn = nowTime.split (":");
         if (stre.length != 2) {
             return false;
         }
         var b = new Date ();
         var e = new Date ();
         var n = new Date ();
     
         b.setHours (strb[0]);
         b.setMinutes (strb[1]);
         e.setHours (stre[0]);
         e.setMinutes (stre[1]);
         n.setHours (strn[0]);
         n.setMinutes (strn[1]);
    
        if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
            console.log("当前时间是:" + n.getHours () + ":" + n.getMinutes () + ",");
             return true;
         } else {
            console.log("当前时间是:" + n.getHours () + ":" + n.getMinutes () + ",不在该时间范围内!");
             return false;
        }
     }
  • 相关阅读:
    复制文本插件
    关于datatable的自定义列 并排序的功能
    jquery
    ztree的一个小功能
    vue+codemirror 笔记一
    jointjs-3-defaultRouter
    jointjs笔记-线的设置
    joint 笔记
    【Burp suite】网站登录密码暴力破解学习心得(初级)
    【DVWA(三)】暴力破解 & burpsuite 的简单使用(抓包暴力破解登录密码)
  • 原文地址:https://www.cnblogs.com/mumublog/p/6062037.html
Copyright © 2011-2022 走看看