function interval(time){
let nowDate = +new Date()//+new Date()这种写法是得到时间戳形式
let futureDate = +new Date(time)
let intervalTime = (futureDate-nowDate)/1000 //转化为秒方便后续计算
//以下为数学方式 将秒换算成(天时分秒)
let d = parseInt(intervalTime/60/60/24)
let h = parseInt(intervalTime/60/60%24)
let m = parseInt(intervalTime/60%60)
let s = parseInt(intervalTime%60)
return d+"天"+h+"时"+m+"分"+s+"秒"
}
console.log(interval("2021-12-07 21:05:00"))