JS - 倒计时器

js 代码

  function GetRTime1(){
    var EndTime1= new Date('2018/03/28 00:00:00');
    var NowTime1 = new Date();
    var t1 =EndTime1.getTime() - NowTime1.getTime();
    var d1=0;
    var h1=0;
    var m1=0;
    var s1=0;
    if(t1>=0){
      d1=Math.floor(t1/1000/60/60/24);
      h1=Math.floor(t1/1000/60/60%24);
      m1=Math.floor(t1/1000/60%60);
      s1=Math.floor(t1/1000%60);
    }
    document.getElementById("t_d1").innerHTML = d1 + " 天";
    document.getElementById("t_h1").innerHTML = h1 + " 时";
    document.getElementById("t_m1").innerHTML = m1 + " 分";
    document.getElementById("t_s1").innerHTML = s1 + " 秒";
  }
  setInterval(GetRTime1,0);

html 代码

<code id="t_d1">00</code>
<code id="t_h1">00</code>
<code id="t_m1">00</code>
<code id="t_s1">00</code>