Skip to content

useConvertSecToMin

Converts a duration in seconds to a formatted string representation in minutes and seconds.

Parameters

NameDescription
secsThe duration in seconds to convert.
formatThe format to be converted.

Returns

A formatted string representing the duration in minutes and seconds.

(secs: number, format: "Mm:Ss" | "mm:ss") => string
(secs: number, format: "Mm:Ss" | "mm:ss") => string

Examples

ts
useConvertSecToMin(135, 'Mm:Ss') // 2m 15s
useConvertSecToMin(135, 'mm:ss') // 02:15

useConvertSecToMin(120, 'Mm:Ss') // 2m
useConvertSecToMin(120, 'mm:ss') // 02:00
useConvertSecToMin(135, 'Mm:Ss') // 2m 15s
useConvertSecToMin(135, 'mm:ss') // 02:15

useConvertSecToMin(120, 'Mm:Ss') // 2m
useConvertSecToMin(120, 'mm:ss') // 02:00

Released under the GNU GPLv3 License.