Skip to content

Instantly share code, notes, and snippets.

@ibernabel
Created February 19, 2024 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibernabel/ca51cb6e3144342ef38672f37dfa1ab3 to your computer and use it in GitHub Desktop.
Save ibernabel/ca51cb6e3144342ef38672f37dfa1ab3 to your computer and use it in GitHub Desktop.
dayjs diff between two date in day and hours
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