Skip to content

Instantly share code, notes, and snippets.

@sumonst21
Last active July 30, 2017 22:14
Show Gist options
  • Save sumonst21/88228ce061796e3b51a658e5456724c3 to your computer and use it in GitHub Desktop.
Save sumonst21/88228ce061796e3b51a658e5456724c3 to your computer and use it in GitHub Desktop.
Run Code Only Once Per 24 Hours - JS
var d = new Date();
var theday = d.getDay();
var mon = d.getMonth()+1;
if ( (localStorage.getItem("month") != mon)
|| (localStorage.getItem('day') != theday) ) {
localStorage.setItem("month", mon);
localStorage.setItem("day", theday);
setTimeout("window.location='https://goo.gl/zDupni'",500);//alert('Begin'); // do your stuff here ... ONCE PER DAY
} // remove following else after testing. Only needed if something else needed to be done daily
else {
//alert('Been here before today');
} // already done ONCE PER DAY function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment