Reputation: 101
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.
Upvotes: 0
Views: 55
Reputation: 1158
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()
Upvotes: 3