如何根据我的时区获得一个月的实际第一天?

How to get actual first day of the month, possible with my time zone?

我正在尝试获取该月的第一天,但​​我获取的是 UTC 值。我想我需要我的语言环境日期?

我自己试过:

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [gregorian components:( NSYearCalendarUnit |
                                                          NSMonthCalendarUnit | NSDayCalendarUnit ) fromDate:[NSDate date]];
[dateComponents setDay:1];
NSLog(@"%@", [gregorian dateFromComponents:dateComponents]);

并且它正确地打印了 2015-04-30 22:00:00 +0000 ,这将是在添加 2 小时(在我的例子中)时区差异之后的 5 月 1 日。只需重新检查您的代码,好像 self.calender.currentDate 给出了错误的月份?