Skip to content

Instantly share code, notes, and snippets.

@sayyedhammadali
Created October 2, 2021 21:52
Show Gist options
  • Save sayyedhammadali/6fd5c01e82207547978e9296a76f3b00 to your computer and use it in GitHub Desktop.
Save sayyedhammadali/6fd5c01e82207547978e9296a76f3b00 to your computer and use it in GitHub Desktop.
Find the number of days between two dataes
const dayDif = (date1, date2) => Math.ceil(Math.abs(date1.getTime() - date2.getTime()) / 86400000)
dayDif(new Date("2020-10-21"), new Date("2021-10-22"))
// Result: 366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment