Skip to content

Instantly share code, notes, and snippets.

@afrijaldz
Created February 4, 2021 08:27
Show Gist options
  • Save afrijaldz/8fbf9b21e052d0389a4458944aad7ecf to your computer and use it in GitHub Desktop.
Save afrijaldz/8fbf9b21e052d0389a4458944aad7ecf to your computer and use it in GitHub Desktop.
get difference days from two days
const date1 = new Date('12/31/2020');
const date2 = new Date();
const difference = date1.getTime() - date2.getTime();
const days = Math.abs(Math.ceil(difference / (1000 * 3600 * 24)));
console.log(days + ' days to go to new year!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment