Reputation: 9400
What's the correct format to parse this string:
"Mon, 14 Mar 2011 15:36:00 GMT"
into a NSDate using NSDateFormatter?
Upvotes: 0
Views: 159
Reputation: 1983
NSString *dateStr = [NSString stringWithString:@"Mon, 14 Mar 2011 15:36:00 GMT"];
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"EEE, d MMM yyyy HH:mm:ss zzzz"];
NSDate *date = [dateFormat dateFromString:dateStr];
Upvotes: 0
Reputation: 6734
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss zzzz"];
NSDate *myDate = [dateFormatter dateFromString:strPubDate];
Upvotes: 2