Skip to content

Instantly share code, notes, and snippets.

@rayhanadev
Last active July 4, 2021 15:01
Show Gist options
  • Save rayhanadev/df014dbb5d872d89f27f36325dcaaf40 to your computer and use it in GitHub Desktop.
Save rayhanadev/df014dbb5d872d89f27f36325dcaaf40 to your computer and use it in GitHub Desktop.
Interval Based Function Caller
function startInterval() {
(function loop() {
var now = new Date();
// Set the time here
if (now.getDay() === 0 && now.getHours() === 0 && now.getMinutes() === 59) {
/* Place function to execute here */
}
now = new Date();
var delay = 60000 - (now % 60000);
setTimeout(loop, delay);
})();
}
if (_startInterval) startInterval();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment