Skip to content

Instantly share code, notes, and snippets.

@oguzhancvdr
Created October 22, 2022 19:54
Show Gist options
  • Select an option

  • Save oguzhancvdr/50398a53ba7f718941e9d5f1461161de to your computer and use it in GitHub Desktop.

Select an option

Save oguzhancvdr/50398a53ba7f718941e9d5f1461161de to your computer and use it in GitHub Desktop.
const dayDiff = (date1, date2) => Math.ceil(Math.abs(date1.getTime() - date2.getTime()) / 86400000);
dayDiff(new Date("2021-10-21"), new Date("2022-02-12"))
// Result: 114
@oguzhancvdr
Copy link
Copy Markdown
Author

The number of days between two dates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment