I am trying to get NSDate from string but its returning nil.
I tried this:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-mm-dd'T'HH:mm:ss'Z'"];
NSDate *date = [dateFormatter dateFromString:@"2010-05-07T10:12:32UTC"];
NSLog(@"Success date=%@",[date description]);
Thanks
Your date format string expects the date to end with a literal
Z. But your date ends with the stringUTC. There are several ways to fix this.@"yyyy-mm-dd'T'HH:mm:ss'UTC'".@"2010-05-07T10:12:32Z".Or, you could change your date format string to:
@"yyyy-mm-dd'T'HH:mm:ssz". This will recognize some common 3-letter time zone names, such as PDT for Pacific Daylight Time. Unfortunately, however, it will not recognize UTC as a time zone name (you’d have to use “GMT”).