I want to convert string Thu, Nov 22, 2012 to NSDate.
I’ve tried this:
NSString *str = @"Thu, Nov 22, 2012";
[dateFormat setDateFormat:@"EEE,MMM dd yyyy"];
NSDate *date = [dateFormat dateFromString:str];
NSLog(@"date: %@",date);
But i’m getting null.
What am i doing wrong ?
Since you are using the correct format letters, you just need to fix commas (and spacing) like that:
EEE, MMM dd, yyyyalthough one E would even be enough (E, MMM dd, yyyy).See the format reference.