How to convert a UTC date to NSDate?

Posted by Sheehan Alam on Stack Overflow See other posts from Stack Overflow or by Sheehan Alam
Published on 2010-03-24T02:37:36Z Indexed on 2010/03/24 2:43 UTC
Read the original article Hit count: 624

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.

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about iphone