I’ve been using this method to convert a regular NSString object to an NSDate, but tried submitting an update to Apple and it was denied. What’s another way to do this in iOS?
NSString *date_str = @"2011-08-12T12:20:00Z";
NSDate *the_date = [NSDate dateWithNaturalLanguageString:date_str locale:[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]];
Thanks in advance!
Use an
NSDateFormatter. Brief example follows:Note that as per Unicode Technical Standard #35,
NSDateFormatterdoesn’t natively support single-letter time-zone identifiers (i.e. Z for zulu time).