问题
I am using the following code to set a date object:
NSDate *date = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
NSDateComponents *components = [gregorian components: NSUIntegerMax fromDate: date];
[components setHour: 18];
[components setMinute: 00];
[components setSecond: 00];
reminderDate = [gregorian dateFromComponents: components];
However, when I NSLog reminderDate I get the following output:
Time: 2012-08-29 17:00:00 +0000
Which is early by one hour, can anyone explain what it is I need to do in order to store the correct date in reminderDate?
Thanks,
Tysin
回答1:
What is your time zone? If you notice, the date that you print has +0 time zone, so if your time zone is +1 is all correct.
来源:https://stackoverflow.com/questions/12177311/nsdate-early-by-1-hour