Answers for "execute a function at a certain time of day js"

0

execute a function at a certain time of day js

window.setInterval(function(){ // Set interval for checking
    var date = new Date(); // Create a Date object to find out what time it is
    if(date.getHours() === 8 && date.getMinutes() === 0){ // Check the time
        // Do stuff
    }
}, 60000); // Repeat every 60000 milliseconds (1 minute)
Posted by: Guest on August-09-2021
0

code that will execute at a certain day and time javascript

var now = new Date();
var millisTill10 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 10, 0, 0, 0) - now;
if (millisTill10 < 0) {
     millisTill10 += 86400000; // it's after 10am, try 10am tomorrow.
}
setTimeout(function(){alert("It's 10am!")}, millisTill10);
Posted by: Guest on August-09-2021
0

call a javascript function at a specific time of day

setInterval(()=>{
let now = new Date();
//86400000 represents 10 hours in milliseconds Change it as you like
if(now.getTime() == 86400000 ){
  //your code
}
}, 1);
Posted by: Guest on July-15-2021

Code answers related to "execute a function at a certain time of day js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language