Last active
October 11, 2020 11:28
-
-
Save yonatansnir/4ac480aa0bfda5e222edbf1780caafbd to your computer and use it in GitHub Desktop.
Calculate Days Between Two Dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function daysBetween(date1, date2){ | |
| const oneDayInMs = 1000*60*60*24; | |
| let diffInMs = Math.abs(date1.getTime() - date2.getTime()) | |
| let result = diffInMs / oneDayInMs; | |
| return Math.floor(result); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment