1window.setInterval(function(){ // Set interval for checking
2 var date = new Date(); // Create a Date object to find out what time it is
3 if(date.getHours() === 8 && date.getMinutes() === 0){ // Check the time
4 // Do stuff
5 }
6}, 60000); // Repeat every 60000 milliseconds (1 minute)
1var now = new Date();
2var millisTill10 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 10, 0, 0, 0) - now;
3if (millisTill10 < 0) {
4 millisTill10 += 86400000; // it's after 10am, try 10am tomorrow.
5}
6setTimeout(function(){alert("It's 10am!")}, millisTill10);