Last active
July 5, 2016 07:47
-
-
Save azakordonets/70bc600908f91bbc9159cd85b6d0268b to your computer and use it in GitHub Desktop.
This file contains 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 dateDiffInMillis = (date1, date2) => | |
Math.abs(date2.getTime() - date1.getTime()); | |
const dayDifferenceInSeconds = (date1, date2) => | |
Math.round(dateDiffInMillis(date1, date2) / 1000); | |
const minuteDifferenceBetweenDates = (date1, date2) => | |
Math.round(dayDifferenceInSeconds(date1, date2) / 60); | |
const hourDifferenceBetweenDates = (date1, date2) => | |
Math.round(minuteDifferenceBetweenDates(date1, date2) / 60); | |
const dayDifferenceBetweenDays = (date1, date2) => | |
Math.round(hourDifferenceBetweenDates(date1, date2) / 24); | |
const formatDate = (date) => | |
`${date.getDate()}-${date.getMonth()}-${date.getFullYear()} ` + | |
`${date.getHours()}:${date.getMinutes()}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment