zoukankan      html  css  js  c++  java
  • js倒计时方法

    1.js设置倒计时日期

      //data 格式MM-dd-yyyy HH:mm:ss

      function ShowTime(data){

        window.setTimeout(function(){this.ShowTime(time);},  1000);

        var serverDay=new Date(data);

        var today=New Date();

        var s_t_time=serverDay.getTime()-today.getTime();

        var ss_time=Math.floor(s_t_time/1000);

        var  day_time=s_t_time/(24*60*60*1000);

        var day=Math.floor(day_time);

         var hours_time=(day_time-day)*24;

         var hh=Math.floor(hours_time);

         var min_time=(hours_time-hh)*60;

         var mm=Math.floor((hours_time-hh)*60);

         var ss=Math.floor((min_time-mm)*60);

          if(day<=0){

              document.write("时间到!哈哈");
           }

           else{

             document.write(day+"天"+hh+"小时"+mm+"分"+ss+"秒");
           }

      }

    ShowTime("1-10-2012 22:06:45");

  • 相关阅读:
    序列操作
    上帝造题的七分钟2 / 花神游历各国
    火柴排队
    pair(对组)用法
    线段树
    链上分治
    Rem与Px的转换
    css中单位px和em,rem的区别
    css网页自适应-1
    css网页自适应-2
  • 原文地址:https://www.cnblogs.com/linsu/p/2318569.html
Copyright © 2011-2022 走看看