Reputation: 2526
I'm getting from my webapp date and time in format:
2012-02-23T23:25:22Z
I tried with different formats but without success.
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss z"];
How to setup NSDateFormater to get this string into NSDate?
Upvotes: 1
Views: 1277
Reputation: 4427
You are using an RFC3339 date time.
Apple uses this recommendation:
[rfc3339DateFormatter setLocale:enUSPOSIXLocale];
[rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
[rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
Upvotes: 2
Reputation: 39988
Updated
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
But what your Z represents here.. I suppose it's not a timezone
Upvotes: 5