function countd(){ var endTime='2017/01/20';//设置结束时间 var endT=new Date(endTime); var newTime=new Date(); var count=endT.getTime()-newTime.getTime(); var day=Math.floor(count/1000/60/60/24); var hours=Math.floor(count/1000/60/60%24); var minute=Math.floor(count/1000/60%60); var seconds=Math.floor(count/1000%60); var body=document.getElementsByTagName('body')[0];//获取放置倒计时的标签 body.innerHTML=day+'天'+hours+'时'+minute+'分'+seconds+'秒';}setInterval(countd,1000);//设置定时器