This question already has an answer here:
I got string of date regarding this format:
2011-12-29T09:09:06-0500
How can I convert this into a date object?
Try this solution
NSString *dateString = @"2011-12-29T09:09:06-0500";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *dateFromString = [dateFormatter dateFromString:dateString];
[dateFormatter release];
NSLog(@" dateFromString %@",dateFromString);
divakar
NSString *date = [[NSDate date] description];
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:<NSString containing date>];
来源:https://stackoverflow.com/questions/8676672/how-to-parse-an-iso8601-date