Skip to content

Instantly share code, notes, and snippets.

@amuntasim
Last active May 2, 2017 14:20
Show Gist options
  • Save amuntasim/d8ec7bcc1ac7447c9026c466cad7dc37 to your computer and use it in GitHub Desktop.
Save amuntasim/d8ec7bcc1ac7447c9026c466cad7dc37 to your computer and use it in GitHub Desktop.
call a javascript method at specific time
var triggered = false;
(function loop() {
var now = new Date();
// here the method will be triggered at 20:28, you can change them as per your need
if (!triggered && now.getHours() === 20 && now.getMinutes() === 28) {
method();
triggered = true;
}
console.log('Now: ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds());
setTimeout(loop, 200);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment