<script>
setInterval(function () { // setInterval 是一个计时器 按照给定的时间每秒刷新
let now = new Date() // 获取现在的时间
let time= new Date('2020-08-31 19:00:00')
let sec = (time - now) / 1000
let h = Math.floor(sec / (60 * 60))
let m = Math.floor(sec % (60 * 60) / 60)
let s = Math.floor(sec % (60 * 60) % 60)
h = h < 10 ? '0' + h : h
m = m < 10 ? '0' + m : m
s = s < 10 ? '0' + s : s
console.log([h, m, s].join(':'));
}, 1000)
</script>