code that will execute at a certain day and time javascript

Solutions on MaxInterview for code that will execute at a certain day and time javascript by the best coders in the world

showing results for - "code that will execute at a certain day and time javascript"
Lukas
24 Nov 2018
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)
Jules
18 May 2017
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);