function timer(){
var ts = (new Date( 2015,03,09, 19, 15, 00)) - (new Date());//计算剩余的毫秒数
var dd = parseInt(ts / 1000 / 60 / 60 / 24, 10);//计算剩余的天数
var hh = parseInt(ts / 1000 / 60 / 60 % 24, 10);//计算剩余的小时数
var mm = parseInt(ts / 1000 / 60 % 60, 10);//计算剩余的分钟数
var ss = parseInt(ts / 1000 % 60, 10);//计算剩余的秒数
if(ss<=0){
ss=0;
}
if(mm<=0){
mm=0;
}
if(hh<=0){
hh=0;
}
if(dd<=0){
dd=0;
}
dd = checkTime(dd);
hh = checkTime(hh);
mm = checkTime(mm);
ss = checkTime(ss);
//alert(dd);
//document.getElementById("fen1").innerHTML = dd + "天" + hh + "时" + mm + "分" + ss + "秒";
document.getElementById("fen1").innerHTML = dd;
document.getElementById("fen2").innerHTML = hh;
document.getElementById("fen3").innerHTML = mm;
document.getElementById("fen4").innerHTML = ss;
setInterval("timer()",1000);
}
function checkTime(i)
{
if (i < 10) {
i = "0" + i;
}
return i;
}
timer();