Hi Im trying to convert an NSString to NSDate
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZZZ"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:lastModified];
But when I do a
NSLog(@" date: %@ ", dateFromString);
I get date: (null)
The lastModified string has date in string format as “Tue, 15 Feb 2011 13:30:42 GMT”
What am I doing wrong?
your input (
lastModified) does not match the specified date format.a properly formed string representation of the time specified by
lastModifiedfor the date format is:"2011-02-15 13:30:42 GMT", but you’re passing"Tue, 15 Feb 2011 13:30:42 GMT".