I have a string that is UTC and would like to convert it to an NSDate.
static NSDateFormatter* _twitter_dateFormatter;
[_twitter_dateFormatter setFormatterBehavior:NSDateFormatterBehaviorDefault];
[_twitter_dateFormatter setDateFormat:@"EEE MMM dd HH:mm:ss ZZZ yyyy"];
[_twitter_dateFormatter setLocale:_en_us_locale];
NSDate *d = [_twitter_dateFormatter dateFromString:sDate];
When I go through the debugger d is nil even though sDate is “2010-03-24T02:35:57Z”
Not exactly sure what I’m doing wrong.
Ditto on the need to alloc/init your NSDateFormatter object, but you have another problem too: your Date format string does not match the actual date you’re giving it.
That format string would match something like:
See the unicode standard for the meaning of the date format string.