Skip to content

Instantly share code, notes, and snippets.

@FlyInk13
Last active December 12, 2017 03:49
Show Gist options
  • Save FlyInk13/cadbdf21f3c593eddba4cbb4c3bf7bb4 to your computer and use it in GitHub Desktop.
Save FlyInk13/cadbdf21f3c593eddba4cbb4c3bf7bb4 to your computer and use it in GitHub Desktop.
Устанавливает интервал от времени на javascript / Sets the interval from time
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