You are logging the date in GMT time zone (+0000). Try logging this:
NSLog(@"new date: %@", [dayOneInCurrentMonth descriptionWithLocale:[NSLocale systemLocale]]);
Pregunta
I am trying to get an NSDate object from the first day of the current month. I use the following code:
NSDateComponents *components = [c components:(NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayOrdinalCalendarUnit | NSDayCalendarUnit) fromDate:[NSDate date]];
components.day = 1;
NSDate *dayOneInCurrentMonth = [c dateFromComponents:components];
However when I log this date, it gives me the day before
day one = 2013-09-30 22:00:00 +0000
Solución
You are logging the date in GMT time zone (+0000). Try logging this:
NSLog(@"new date: %@", [dayOneInCurrentMonth descriptionWithLocale:[NSLocale systemLocale]]);