Skip to content

Instantly share code, notes, and snippets.

@nithesh1992
Forked from sayyedhammadali/day-dif.txt
Created October 8, 2021 06:21
Show Gist options
  • Save nithesh1992/9649adc5f3039bd176ca44441d776553 to your computer and use it in GitHub Desktop.
Save nithesh1992/9649adc5f3039bd176ca44441d776553 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