Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Last active December 18, 2022 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nocodesupplyco/8408d2eb3e1e487252d3de6a7f4007a1 to your computer and use it in GitHub Desktop.
Save nocodesupplyco/8408d2eb3e1e487252d3de6a7f4007a1 to your computer and use it in GitHub Desktop.
Show/Hide Based on Date/Time
// ".before" is class to show before time, and ".after" is class to show after
window.setInterval(function() {
let current = new Date();
let expiry = new Date("Mar 29, 2020 20:21:00")
if (current.getTime() > expiry.getTime()) {
$('.before').hide();
$('.after').show();
} else if (current.getTime() < expiry.getTime()) {
$('.before').show();
$('.after').hide();
}
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment