File size: 338 Bytes
f27679f
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12

import {  intervalToDuration } from 'date-fns'

export function formatDuration(seconds: number) {
  const duration = intervalToDuration({ start: 0, end: seconds * 1000 })

  const zeroPad = (num: any) => String(num).padStart(2, '0')
  
  const formatted = `${zeroPad(duration.minutes)}:${zeroPad(duration.seconds)}`

  return formatted
}