I am having problems with NSDateFormatter‘s dateFromString method.
I have the following date: Tue, 12 Jul 2011 20:18:26 GMT , but NSDateFormatter doesn’t seem to recognize it and returns (null).
Here’s what I tried:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy HH:MM:SS"];
NSDate *date = [dateFormatter dateFromString:@"Tue, 12 Jul 2011 20:18:26 GMT"];
[dateFormatter release];
NSLog(@"Date: %@",date);
What am I doing wrong?
In this case you need to set
dateFormatto match the format of the date in the string. Try following: