Last active
August 29, 2015 14:11
-
-
Save ZacharyWeiner/045cbccce8750aac5b74 to your computer and use it in GitHub Desktop.
NSDate NSDateFormatter & NSString - iOS
This file contains 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
-(NSDate *) workWithDate | |
{ | |
NSDate *date = [NSDate date]; | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"yyyy-MM-dd"]; | |
NSString *dateAsString = [formatter stringFromDate:date]; | |
NSLog(@"Date as String: %@", dateAsString); | |
NSLog(@"Date from Date: %@", date); | |
NSDate *fromString = [formatter dateFromString:dateAsString]; | |
NSLog(@"Date from Converted Date: %@", fromString); | |
return fromString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment