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;
        }
     }
  • 相关阅读:
    向上造型
    Service与Activity通信
    adb报错:no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html]
    13-AB Test学习
    1-端到端机器学习项目
    12-数据分析框架
    2-电影推荐案例学习
    11-pyecharts使用Tab不完全代码示例
    22-基于Python构建GRPC服务
    akka练习
  • 原文地址:https://www.cnblogs.com/mumublog/p/6062037.html
Copyright © 2011-2022 走看看