Created
February 1, 2021 18:03
-
-
Save psynewave/9006cd63867d69bfb5c97bf9ed6d620a to your computer and use it in GitHub Desktop.
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
const getDaysBetweenDates = (dateStart, dateEnd) => (new Date(dateEnd) - new Date(dateStart)) / (1000 * 3600 * 24); | |
getDaysBetweenDates('1/21/2020', '1/21/2021'); // 366 leap year | |
getDaysBetweenDates('1/21/2019', '1/20/2020'); // 365 | |
getDaysBetweenDates(new Date('08/04/2020'), new Date('08/24/2020')); | |
getDaysBetweenDates('08/04/2020','08/24/2020'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment