Created
July 21, 2022 13:22
-
-
Save dayaki/cb0346a6acb93f5b500dbec5b87d0fef to your computer and use it in GitHub Desktop.
Revisions
-
dayaki created this gist
Jul 21, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ let myVar = 10; function scheduleReset() { // get current time let reset = new Date(); // update the Hours, mins, secs to the 24th hour (which is when the next day starts) reset.setHours(24, 0, 0, 0); // calc amount of time until restart let t = reset.getTime() - Date.now(); setTimeout(function() { // reset variable myVar = 1; // schedule the next variable reset scheduleReset(); }, t); } scheduleReset();