Date difference in day, month, years

Hi, I want to find the difference b\w 2 dates which i have done and have a value in milliseconds.

remainingDate = Math.abs(Date.parse(mytDate) - Date.parse(currentDate));
It gives value in millisecond i want to covert the value into remaining days, month and year, (i.e if myDate = 26 Oct 2020, and current date is 24 July 2017. The output should be like: 2 days, 3 months, 3 years.

How can I get like this output?
ThankYou.

Use the modulo division operator (%) recursively. Google the amount of milliseconds in a year, day and month etc and divide the milliseconds into parts of those respective sizes

Does date-fns’ distanceInWords() do what you want?

Its a bit of help, I don’t want to use momentjs, as its a small app and don’t want to add a plugin, but in the end for accurate date difference its the only option. So find the solution with momentjs. Thanks :slight_smile:

I’m confused by what you write here. I’m not suggesting moment, but rather date-fns, which is much more lightweight.

you find solution ??