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.

Dinesh Namburi
  • 301
  • 3
  • 14
GShrest
  • 101
  • 1
  • 9

1 Answers1

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

dikuw
  • 1,134
  • 13
  • 22