Possible Duplicate:
Wrong time from NSDateFormatter
NSDate is 5 hours off
I am trying to convert NSString to NSDate with the code
result = @"2012-02-09";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:result];
[dateFormatter release];
NSLog(@"date: %@", dateFromString);
But the date conversion giving an incorrect result, in logs:
2012-02-07 13:08:29.553 Document[611:15503] date: 2012-02-08 19:00:00 +0000
Can someone please tell me whats wrong with my code?
To use NSLog to display a date you should use your formatter so that the NSDate will be formatted with your TimeZone: