'Convering a whole number to this format 120m59s

Ive looked online and searched and asked but no one can answer my question I need to format a whole number Eg: 12059 to look like this 120m59s. Ive tried with moment.js to do it and Im getting an error. TypeError: moment__WEBPACK_IMPORTED_MODULE_1___default.a.duration(...).format is not a function

if I do it like so data.total ? moment.duration(data.total, 'seconds').format('m [min] s [sec]') : '0'

Could someone please help ?



Solution 1:[1]

figured it out - moment.utc(moment.duration(data.total, 'seconds').asMilliseconds()).format('h[h]m[m]s[s]')

Took me a few struggles and costed a handful of hairs but I hear balding is the new thing.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Faziki