I'm trying to make a timed alert that goes off at midnight, and the code so far:
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
h = checkTime(h);
m = checkTime(m);
s = checkTime(s);
var t = setTimeout(function(){startTime()},1000);
if (h==0&&m==0&&s==0){window.alert("The date is "+new Date()); location.reload();}
}
goes off at every hour, not every 24 hours like it should. I also could not find where the bug is because it all looks like it should work. Can you please help me?