I tried to set NSDateFormatter for year, like this:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy"];
NSLog(@"**> %@",[dateFormatter dateFromString:@"2012"]);
[dateFormatter release];
But it prints: **> 2011-12-31 22:00:00 +0000
Maybe someone could help me about this
This has to do with the timezone difference between UTC (GMT) and your time zone (you’re probably in GMT+2). NSDate is in UTC by default. That’s why [NSDate date] can deviate from the local time.
The following code should output Jan 1, 2012:
or