MaciekWrocław MaciekWrocław - 1 year ago 63
iOS Question

NSString to NSDate conversion. Problem with "2011-08-24T14:06:10Z"

How to convert that string:


to NSDate using NSDateFormatter. I don´t know which format to set. What does this ´T´and ´Z´mean?

Answer Source

This is a RFC3339 date format.

You can parse it using:

NSDateFormatter* rfc3339DateFormatter = [[NSDateFormatter alloc] init];

[rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];

NSDate* date = [rfc3339DateFormatter dateFromString:yourString]; 

[aDateFormatter release];

more information is available on the Apple Formatting Dates Documentation and you can also find more information on the RFC3339 date format (regarding the T and Z) in this section of the RFC3339 standard

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download