倒计时
function countTime(time){
var nowTime = +new Date() //获取此刻的时间
var inputTime = +new Date(time) //输入的时间
times = (inputTime - nowTime) / 1000 //获取剩余的总毫秒数 剩余的总秒数 = 输入的时间毫秒数 - 此刻的时间毫秒数
day = parseInt( times / 60 / 60 /24 ) >10 ? parseInt( times / 60 / 60 /24 ) : "0" + parseInt( times / 60 / 60 /24 ) //还剩多少天
h = parseInt( times/ 60 /60 %24) >10 ? parseInt( times/ 60 /60 %24) : "0" + parseInt( times/ 60 /60 %24) //小时
m =parseInt( times / 60 % 60 )>10 ? parseInt( times / 60 % 60 ) : "0" + parseInt( times / 60 % 60 ) //分钟
s =parseInt( times % 60) > 10? parseInt( times % 60) : "0" + parseInt( times % 60)
return day + '天' + h + '小时' + m + '分钟' + s + '秒'
}
console.log(countTime("2021-12-4 19:00:00"));