标签:htm 倒计时 document tin innerhtml date() 包含 floor interval
function timeCount(){
var nowTime=Date.parse(new Date());
var toTime=Date.parse(new Date(‘2018 01 01‘));
var jiange=(toTime-nowTime)/1000;
var day=Math.floor(jiange/3600/24);
var hh=Math.floor((jiange%(3600*24))/(60*60));
var mm=Math.floor(((jiange%(3600*24))%(60*60))/60);
var ss=((jiange%(3600*24))%(60*60))%60;
var s=‘现在距离2018年还剩:‘+day+‘ 天 ‘+hh+‘ 小时 ‘+mm+ ‘ 分 ‘+ss+‘ 秒 ‘;
document.innerHTML=s;
}
setInterval(timeCount,1000);
计算从现在到明年的倒计时(包含天,时,分,秒),每秒更新一次
标签:htm 倒计时 document tin innerhtml date() 包含 floor interval
原文地址:http://www.cnblogs.com/jessicaWy/p/7235572.html