Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSDateFormatter returns nil with format YYYY-MM-ddTHH:mm:ssZ

I'm trying to get the NSDate from a string with the following format 'YYYY-MM-ddTHH:mm:ssZ' using the NSDateFormatter. The NSDateFormatter returns always nil. Here is how I tried to do that:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
NSDate *dateFromString = [dateFormatter dateFromString:@"2013-08-09T18:30:00+02:00"];
like image 210
andreaspfr Avatar asked May 27 '14 20:05

andreaspfr


1 Answers

that would be a better formatter.

[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
like image 170
holex Avatar answered Oct 21 '22 08:10

holex