如何在moment.js持续时间上使用format()? [英] How to use format() on a moment.js duration?
问题描述
我可以在持续时间对象上使用 moment.js format
方法吗?我在文档的任何地方都找不到它,并且它也不是持续时间对象的属性.
Is there any way I can use the moment.js format
method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
我希望能够做类似的事情:
I'd like to be able to do something like:
var diff = moment(end).unix() - moment(start).unix();
moment.duration(diff).format('hh:mm:ss')
此外,如果还有任何其他可以轻松容纳这种功能的库,我会对建议感兴趣.
Also, if there are any other libraries which can easily accommodate this sort of functionality, I'd be interested in recommendations.
谢谢!
推荐答案
我们正在考虑为moment.js中的持续时间添加某种格式.参见 https://github.com/timrwood/moment/issues/463
We are looking into adding some kind of formatting to durations in moment.js. See https://github.com/timrwood/moment/issues/463
其他可能有帮助的库是 http://countdownjs.org/和
A couple other libraries that might help out are http://countdownjs.org/ and https://github.com/icambron/twix.js
这篇关于如何在moment.js持续时间上使用format()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!