Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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)
Comment

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery ajax form submit example 
Javascript :: Divide the number in js 
Javascript :: secure random nodejs 
Javascript :: setstate find opject in state and update 
Javascript :: jquery 
Javascript :: javascript window 
Javascript :: get the last array element javascript 
Javascript :: js addeventlistener foreach 
Javascript :: set lodash 
Javascript :: jquery loop 0 to 10 
Javascript :: react app 
Javascript :: combine 2 arrays javascript 
Javascript :: nodejs download file 
Javascript :: javascript fullscreen 
Javascript :: Get element id by name 
Javascript :: how to get last child element in javascript 
Javascript :: summation js 
Javascript :: js password check 
Javascript :: express js delete request 
Javascript :: how to change css variable in javascript 
Javascript :: javascript exponential 
Javascript :: jsx inline style 
Javascript :: how to add to an array js 
Javascript :: bodyparser express deprecated 
Javascript :: javascript timestamp to date 
Javascript :: js match any number string 
Javascript :: javascript fetch request GET 
Javascript :: index of row jquery 
Javascript :: upload file angular 
Javascript :: how to create node js server 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =