Format a duration ( from seconds ) using date-fns

According to the example code in date-fns/date-fns#229 (comment), we can now use intervalToDuration to convert seconds (passed as an Interval) to a Duration, which can then simplify formatting as desired by the OP: import { intervalToDuration } from ‘date-fns’ const seconds = 10000 intervalToDuration({ start: 0, end: seconds * 1000 }) // { hours: 2, … Read more

tech