倒计时
function countDown (dateStr) { var end = +new Date(dateStr), start = +new Date(), during = Math.floor((end - start)/1000); var day = Math.floor( during/(24*60*60) ), t1 = during - (day*24*60*60), hour = Math.floor( t1/(60*60) ), t2 = t1 - hour*60*60, min = Math.floor( t2/60 ), sec = t2%60; return day + '天' + hour + '小时' + min + '分' + sec + '秒'; } setInterval(function(){ var str = countDown('2016-01-01'); document.write(str); }, 1000);