Last active
November 28, 2016 05:53
-
-
Save blackmiaool/db8d11e51f489c31d76e540bd3e8e7a4 to your computer and use it in GitHub Desktop.
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
function dailyTask(time, task) { | |
var gap = (new Date("1970-1-1 " + time)).getTime() - (Date.now()) % (24 * 36e5); | |
if (gap < 0) { | |
gap += 24 * 36e5; | |
} | |
setTimeout(function() { | |
task(); | |
setInterval(task, 24 * 36e5); | |
}, gap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment