I would like to check the minute, until I get to :00, :05, :10, etc minutes, then set to 5 minutes (on the minute) and continue on during the application. Is there a better way to do this? Do I need a clearTimeout? Please help and thanks!
Goal: Check the minute, once on 00
// Set to 1 minute initially.
let interval = 60000;
function timeCheck() {
const date = getNow();
console.log("checking...", `${dayjs(date).hour()}:${dayjs(date).minute()}:${dayjs(date).second()}`);
// Check browser time in minutes for 00, 05, 10, 15, 20, etc.
if (dayjs(date).minute() % 5 === 0) {
// Set to 5 minute.
interval = 300000;
...
}
setTimeout(timeCheck, interval);
}
clearTimeout(timeCheck);
timeCheck();