0

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 
the_critic
  • 12,720
  • 19
  • 67
  • 115

1 Answers1

3

You are logging the date in GMT time zone (+0000). Try logging this:

NSLog(@"new date: %@", [dayOneInCurrentMonth descriptionWithLocale:[NSLocale systemLocale]]);

Joel
  • 15,654
  • 5
  • 37
  • 60