Is setInterval method reliable for longer hours?
I have a requirement to trigger functions for once everyday and/or once everyweek.
So am using setInterval(myFunc, 86400000)
//For one day. similarly calculated number of milliseconds for one week
Is this a good approach. or is there anyother technique i can use.
I think a good option would be,
when the web page opens first store the date to local storage, when its open normally check the date in local storage every minute and then validate it and take action.
setIterval sounds like a very bad way of doing it here...
On start up get the data,
save the date using localStorage.setItem("date", datevariblename);
on load or everytime you in the set interval use
localStorage.getItem("date")
to get the date value
Then do what every comparsion is required between current date and save date
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With