javascript 到将来某个时间(2020-5-20)的倒计时
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('2020-11-23');
document.write(str +"<br>");
}, 1000);