将整数转换为此格式120M59

发布于 2025-01-24 23:58:25 字数 306 浏览 3 评论 0原文

香港专业教育学院在网上看,搜索和问,但是没有人能回答我的问题,我需要格式化整个数字:12059看起来像120m59。 Ive尝试了MONT.JS进行操作,然后我遇到了错误。 typeError:MONM__WEBPACK_IMPORTED_MODULE_1 ___ DEFAULT.A.DURATION(...)。格式不是函数

如果我像SO data.total一样? Moment.Duration(Data.Total,'seconds')。格式('m [min] s [sec]'):'0'

有人可以帮忙吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清醇 2025-01-31 23:58:25

将其弄清楚 - moment.utc(Moment.Duration(data.Total,'seconds')。asmilliseconds())。格式('H [H] m [m] m [m] s [s]')>

我花了一些挣扎,花了几头发,但我听说秃顶是新事物。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文