Possible Duplicate:
NSDate / NSDateFormatter returning GMT on iPhone iOS 4.3
When the following code is executed
NSString *inputDateString=@"2012-10-19 19:37:54";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *test=[formatter dateFromString:inputDateString];
the value of “test” is 2012-10-19 23:37:54 +0000 rather than a date value equivalent to the inputDateString. Why is the date being converted to GMT?
EDIT: How do I take an input string date and and convert it to an equivalent NSDate object?
NSDatedoesn’t store timezones, nor does it care about them.NSDateonly stores the time that has passed since a given reference date (january 1st 2001). When you use yourNSDateFormatterlike this, it will assume that the timezone of the date matches the users current timezone when converting the string to the date object, however, when you useNSLogto check the date, it doesn’t have any timezone information. Keep in mind though, that the date is still correct and equal to the input value.