Skip to content

Instantly share code, notes, and snippets.

@thezacharytaylor
Created February 18, 2022 18:54
Show Gist options
  • Save thezacharytaylor/f23405e8648f8db444f411d354fb3a88 to your computer and use it in GitHub Desktop.
Save thezacharytaylor/f23405e8648f8db444f411d354fb3a88 to your computer and use it in GitHub Desktop.
Countdown till Crimmus or any other date you want to use.
// Credit: https://www.w3resource.com/javascript-exercises/javascript-basic-exercise-9.php
today = new Date();
let cmas = new Date(today.getFullYear(), 11, 25);
if (today.getMonth() == 11 && today.getDate() > 25) {
cmas.setFullYear(cmas.getFullYear() + 1);
}
let one_day = 1000 * 60 * 60 * 24;
console.log(Math.ceil((cmas.getTime() - today.getTime()) / (one_day)) + " days left until Christmas!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment