Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created November 15, 2020 13:33
Show Gist options
  • Save AitorAlejandro/27ae8585847ca23bfb7e02f6b676d8bb to your computer and use it in GitHub Desktop.
Save AitorAlejandro/27ae8585847ca23bfb7e02f6b676d8bb to your computer and use it in GitHub Desktop.
How to get the difference (in days) between two dates
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
(dateFinal - dateInitial) / (1000 * 3600 * 24);
// Example
getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment