Created
October 28, 2016 07:54
-
-
Save u01jmg3/e20fe9acccd8becdb6ca67f45fe22afc to your computer and use it in GitHub Desktop.
Synchronise a timer to fire every new minute on a clock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var secondsRemaining; | |
let run_function = () => { | |
// | |
} | |
$(document).ready(function(){ | |
run_function(); | |
var time = new Date(); | |
secondsRemaining = (60 - time.getSeconds()) * 1000; | |
setTimeout(function(){ | |
run_function(); | |
setInterval(function(){ | |
run_function(); | |
secondsRemaining = 0; | |
}, 60000); // 1 minute | |
}, secondsRemaining); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment