1

I want to get the first day and date of the previous month, and the last day and date of the next month. For example, the current month is April. I want 1st March and 31st May.

How do I get this info from NSDate?

Although there are solutions to get first day of current month, I think it won't help me to get first day of previous month and last day of next month.

I have already tried:

NSDateComponents *dateComponents = [gregorian components:( NSYearCalendarUnit |
NSMonthCalendarUnit | NSDayCalendarUnit ) fromDate:[NSDate date]];

But here [NSDate date] is current date, but I want prev and next dates.

iOSDev
  • 3,617
  • 10
  • 51
  • 91

0 Answers0