0

I have two javascript dates:

var d1 = new Date(1886937778);
var d2 = new Date(1536937222);

I would link the difference between d1 and d2 to be displayed in a format such as "1 hour 5 minutes" or "2 months 10 hours" etc. Is there a library that does something like this?

Thank you.

4

1 Answer 1

3

I would use moment.js with the moment-precise-range plug-in

The moment.preciseDiff() function will give you your difference which you can then format however you like using .format()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.