I think a good option would be
when a web page opens, first save the date in local storage, when its open usually check the date in local storage every minute and then check it and take action.
setIterval sounds like a very bad way to do it here ...
When you start, get the data,
save the date using localStorage.setItem("date", datevariblename);
at boot time or every time you use the set interval localStorage.getItem("date") to get the date value
Then do what is required for each sort between the current date and the save date.
source share