I want to get a list of all the months that exists between the 2 dates in JS. For ex:
'2021-04-25' to '2021-05-12' should return [4,5] // case when num difference between dates is less than 30 days
'2021-04-25' to '2021-08-12' should return [4,5,6,7,8]
'2021-10-25' to '2022-02-12' should return [10,11,12,1,2]
The following code works but doesn't give the right result for '2021-04-25' to '2021-05-12'. it returns only [4]
I tried examples here JavaScript: get all months between two dates? but momentjs not giving endMonth if days <30