How to use format() on a moment.js duration? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to use format() on a moment.js duration? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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();

Also, if there are any other libraries which can easily accommodate this sort of functionality, I’d be interested in recommendations.



We are looking into adding some kind of formatting to durations in moment.js. See

A couple other libraries that might help out are and

We are here to answer your question about How to use format() on a moment.js duration? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji