let timer = null
function timeFunc() {
const date = new Date()
const mins = date.getMinutes() % 10
const ticktack = (10 - mins) * 60 * 1000
timer = setTimeout(timeFunc, ticktack)
if (mins == 0) {
console.log('整分了')
}
}
timeFunc()
let timer = null
function timeFunc() {
const date = new Date()
const hours = date.getHours()
const mins = date.getMinutes()
const now = date.getTime()
const targetTime = new Date().setHours(8, 30, 0)
let remTime = targetTime >= now ? (targetTime - now) : (targetTime + 86400000 - now)
hourTimer = setTimeout(timeFunc, remTime)
if (hours === 8 && mins === 30) {
console.log('8:30了')
}
}
timeFunc()