Created
February 19, 2024 21:25
-
-
Save ibernabel/ca51cb6e3144342ef38672f37dfa1ab3 to your computer and use it in GitHub Desktop.
dayjs diff between two date in day and hours
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 date1 = dayjs('2021-03-13'); | |
const date2 = dayjs(); | |
let hours = date2.diff(date1, 'hours'); | |
const days = Math.floor(hours / 24); | |
hours = hours - (days * 24); | |
console.log('Days: ', days); | |
console.log('Hours: ', hours); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment