现在的位置: 首页 > 综合 > 正文

一个很瓜的倒计时算法(js)

2013年06月05日 ⁄ 综合 ⁄ 共 630字 ⁄ 字号 评论关闭

function GetValue()
{
    var theMoment = new Date();     
    var date=new Date("2008","05","12","14","28","04.0");       
    var temp = theMoment.getTime() - date.getTime();
  
    var dayCount = Math.floor(temp / (1000 * 60 * 60 * 24));  
    temp = temp -  dayCount * (1000 * 60 * 60 * 24);
   
    var hourCount = Math.floor( temp / (1000 * 60 * 60) );
    temp = temp - hourCount * (1000 * 60 * 60 );
  
    var minCount = Math.floor( temp / (1000 * 60) );
    temp = temp - minCount * ( 1000 * 60 );
  
    var secCount = Math.floor( temp / 1000 );   
   
    dateTime.innerText = ("距离5月12日已有" + dayCount + "天" + hourCount + "小时" + minCount + "分" + secCount + "秒").toString();
    window.setTimeout("GetValue();", 1000);
}

function frm_Load()
{
   GetValue();
}

抱歉!评论已关闭.