• Time倒计时


    commitTimeDate = new Date("2016/11/9 10:02:40").getTime() + 24*60*60*1000;//截止时间
    myDate = new Date();//获取当前时间
    currentTime=myDate.getTime();//当前时间换成毫秒
    deadlineTime = commitTimeDate -  currentTime;//时间差
    let reminderHour = Math.floor(deadlineTime / (1000 * 60 * 60));//倒计时要写的小时
    let reminderSecond = Math.floor(deadlineTime / (1000 * 60)- reminderHour*60);//倒计时要填的分钟
    let reminderMinute = Math.floor(deadlineTime / 1000 - reminderSecond*60 - reminderHour*60*60);//倒计时要填的秒

     jQuery:

    <body>
            <div class="time">
                <span class="days"></span>days:
                <span class="h"></span>hour:
                <span class="s"></span>sec:
                <span class="m"></span>min
            </div>
            <script type="text/javascript" src="../js/jquery/jquery-1.11.3.min.js" ></script>
            <script type="text/javascript">
            
            function GetRTime(){
                commitTimeDate = new Date("2017/03/15 00:00:00").getTime() + 24*60*60*1000;//截止时间
                myDate = new Date();//获取当前时间
                currentTime=myDate.getTime();//当前时间换成毫秒
                deadlineTime = commitTimeDate -  currentTime;//时间差
                
                var reminderHour = Math.floor(deadlineTime / (1000 * 60 * 60));//倒计时要写的小时
                var days = parseInt(reminderHour/24);
                var hours = reminderHour%24;
                var reminderSecond = Math.floor(deadlineTime / (1000 * 60)- reminderHour*60);//倒计时要填的分钟
                var reminderMinute = Math.floor(deadlineTime / 1000 - reminderSecond*60 - reminderHour*60*60);//倒计时要填的秒
                
                $(".days").html(days);
                $(".h").html(hours);
                $(".s").html(reminderSecond);
                $(".m").html(reminderMinute);
            }
            //GetRTime();
            setInterval(GetRTime,0);
            </script>
        </body>

    JavaScript:

        <body>
              <div class="time">
                   <span id="t_d">00天</span>
                   <span id="t_h">00时</span>
                  <span id="t_m">00分</span>
                   <span id="t_s">00秒</span>
              </div>
            <script>
              function GetRTime(){
                var EndTime= new Date('2017/09/20 00:00:00');
                var NowTime = new Date();
                var t =EndTime.getTime() - NowTime.getTime();
                var d=0;
                var h=0;
                var m=0;
                var s=0;
                if(t>=0){
                  d=Math.floor(t/1000/60/60/24);
                  h=Math.floor(t/1000/60/60%24);
                  m=Math.floor(t/1000/60%60);
                  s=Math.floor(t/1000%60);
                }
                document.getElementById("t_d").innerHTML = d + "";
                document.getElementById("t_h").innerHTML = h + "";
                document.getElementById("t_m").innerHTML = m + "";
                document.getElementById("t_s").innerHTML = s + "";
              }
              setInterval(GetRTime,0);
            </script>
        </body>
  • 相关阅读:
    【python学以致用】给PDF添加书签目录,Python解析书签JSON python王者归来 带书签版
    Difference between os.path.exists and os.path.isfile?
    Python的os.listdir配合os.path.isdir不返回目录
    selenium + geckodriver报 Message: Unable to find a matching set of capabilities
    TypeError: string argument without an encoding
    使用gevent时遇到的一些问题记录
    【JavaSE】基本类型包装类(以Integer代表)
    【JavaSE】其他常用类:Math、Random、Calendar、System
    【JavaSE】黑马程序员 刘意 基础部分笔记
    【JavaSE】集合容器的总结(全)
  • 原文地址:https://www.cnblogs.com/xiangru0921/p/6514105.html
Copyright © 2020-2023  润新知