js_倒计时

 1 function countDown(time){
 2     //获取当前距离1970-1-1日的总毫秒数;
 3     var nowTime = +new Date();
 4     //输入的时间距离1970-1-1日的总毫秒数
 5     var inputTime = +new Date(time)
 6     //获取两个时间差的总毫秒数
 7     var times =(inputTime - nowTime)/1000
 8     d=parseInt(times/60/60/24);    //计算天数
 9     h=parseInt(times/60/60%24);    //计算小时
10     m=parseInt(times/60%60);    //计算分钟
11     s=parseInt(times%60);    //计算当前秒数
12     return d+''+h+''+m+''+s+''
13 }
14 console.log(countDown('2020-12-3 18:30:30'))
时间如白驹过隙,忽然而已,且行且珍惜......
原文地址:https://www.cnblogs.com/UnfetteredMan/p/13588768.html