美文网首页
时分秒特效00:20:08

时分秒特效00:20:08

作者: 最好的自己_3d47 | 来源:发表于2020-02-24 13:52 被阅读0次
      var hour,minute,second,alltime;//时 分 秒
      hour=minute=second=alltime=0;//初始化
      var timer=null;  //定时器 
      startTimekeeper()
      function startTimekeeper(){
       timer=setTimeout(function(){
         timeKeeper();
         setTimeout(startTimekeeper(),1000)
       },1000)
      }
     function timeKeeper(){
      alltime++;
      hour=Math.floor(alltime/60/60);
      minute=Math.floor(alltime/60%60);
      second=Math.floor(alltime%60);
      if(hour<10){
            hour = "0" + hour;
      }
      if(minute<10){
          minute = "0" + minute;
      }
      if(second<10){
            second = "0" + second;
      }
      console.log(hour+':'+minute+':'+second);
    }
    

    相关文章

      网友评论

          本文标题:时分秒特效00:20:08

          本文链接:https://www.haomeiwen.com/subject/myqvqhtx.html