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
  • 191
  • 2
  • 14
GShrest
  • 101
  • 8

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,124
  • 14
  • 21