每天定时任务执行
程序员文章站
2022-05-14 15:54:34
...
imeoutFunc(config, func) {
config.runNow && func()
let nowTime = new Date().getTime()
let timePoints = config.time.split(':').map(i => parseInt(i))
let recent = new Date().setHours(...timePoints)
recent >= nowTime || (recent += 24 * 3600000 )
setTimeout(() => {
func()
setInterval(func, config.interval * 3600000 )
}, recent - nowTime)
}