Skip to content

Instantly share code, notes, and snippets.

@majie1993
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save majie1993/6b8e848365845d461b2d to your computer and use it in GitHub Desktop.
Save majie1993/6b8e848365845d461b2d to your computer and use it in GitHub Desktop.
NSString to NSDate
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString* dateString = @"2015/12/9 00:10:00";
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy/MM/dd hh:mm:ss"];
NSDate* date = [dateFormatter dateFromString:dateString];
NSString * updatedStr = [dateFormatter stringFromDate:date];
NSLog(@"time %@", updatedStr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment