Last active
December 12, 2017 03:49
-
-
Save FlyInk13/cadbdf21f3c593eddba4cbb4c3bf7bb4 to your computer and use it in GitHub Desktop.
Устанавливает интервал от времени на javascript / Sets the interval from time
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 setTimeInterval(cb, time, interval) { | |
var x = new Date(); | |
time = (time || "").split(":"); | |
x.now = x.getTime(); | |
x.setHours(time[0] || 0); | |
x.setMinutes(time[1] || 0); | |
x.setSeconds(time[2] || 0); | |
if (x < x.now) x.setDate(x.getDate() + 1); | |
x -= x.now; | |
return setTimeout(setInterval, x % 864e5, cb, interval || 864e5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment