Calculate Time
This Calculate Time
Function is used for
converting the number to minutes and seconds.
CalculateTime
calculateTime.ts
function calculateTime(time: number) {
const minutes = Math.floor(time / 60)
const seconds = time % 60
return `${minutes} : ${seconds}`
}
Usage
timer.tsx
let time: number = 120
const formatTime = calculateTime(time) // 1:09
Last updated on April 9, 2023