Skip to content

Instantly share code, notes, and snippets.

@petronioamaral
Created July 5, 2020 16:18
Show Gist options
  • Save petronioamaral/4d53339cbb9fff77669680278ad5e277 to your computer and use it in GitHub Desktop.
Save petronioamaral/4d53339cbb9fff77669680278ad5e277 to your computer and use it in GitHub Desktop.
var hours = 24; // Reset when storage is more than 24hours
var now = new Date().getTime();
var setupTime = localStorage.getItem('setupTime');
if (setupTime == null) {
localStorage.setItem('setupTime', now)
} else {
if(now-setupTime > hours*60*60*1000) {
localStorage.clear()
localStorage.setItem('setupTime', now);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment