Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save italosantana/e404e001c78a9fde2e210e083c41ee57 to your computer and use it in GitHub Desktop.
Save italosantana/e404e001c78a9fde2e210e083c41ee57 to your computer and use it in GitHub Desktop.
Formating a duration from seconds using date-fns
import { intervalToDuration } from 'date-fns'
const seconds = 10000
intervalToDuration({ start: 0, end: seconds * 1000 })
// { hours: 2, minutes: 46, seconds: 40 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment