I have to calculate the time between two NSDates in Month + Year.
Example 1:
Start Date: September 2018
End Date: May 2019
So I have to get the difference between these two dates and have to display only last 6 months like below:
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
Example 2:
Start Date: October 2019
End Date: December 2019
Output should be:
November 2019
October 2019
I can able to to get the difference between two dates in months using below code:
let components = Calendar.current.dateComponents([.weekOfYear, .month], from: subscriptionDate!, to: currentDate!)
Can anyone please help me on this?
Thank you!