Created
December 10, 2012 23:30
-
-
Save joshdholtz/4254312 to your computer and use it in GitHub Desktop.
iOS Date Parse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
| [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; | |
| [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; | |
| NSDate *date = nil; | |
| NSError *error = nil; | |
| if (![dateFormatter getObjectValue:&date forString:jsonValue range:nil error:&error]) { | |
| NSLog(@"Date '%@' could not be parsed: %@", self, error); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment