Answer the question
In order to leave comments, you need to log in
SetInertval every day?
Good evening, please help me how to implement setInterval every day. Or every new day?
Answer the question
In order to leave comments, you need to log in
Something like this:
https://jsfiddle.net/n08mo1v3/8/
function checkTime() {
const now = Date.now()
const time = localStorage.getItem('timestamp') || null
if (time) {
if (Number(now) - Number(time) >= 1000 * 60 * 60 * 24) {
console.log('Function called')
localStorage.setItem('timestamp', now)
}
} else {
localStorage.setItem('timestamp', now)
}
}
setInterval(checkTime, 1000 * 60)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question