Created
August 15, 2012 12:11
-
-
Save tudormunteanu/3359590 to your computer and use it in GitHub Desktop.
NSDate and NSDateFormatter
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 *df = [[NSDateFormatter alloc] init]; | |
| [df setDateFormat:@"dd.MM.yyy HH:mm"]; | |
| NSString *date = [NSString stringWithFormat:@"%@ %@", schedule.date, schedule.time]; | |
| NSDate *realDate = [df dateFromString:date]; | |
| realDate = [realDate dateByAddingTimeInterval:60*60*2]; | |
| [df release]; | |
| - (NSDate *) dateFromString:(NSString *)dateString forFormat:(NSString *)dateFormatString { | |
| NSDateFormatter *df = [[NSDateFormatter alloc] init]; | |
| [df setDateFormat:dateFormatString]; | |
| NSString *date = [NSString stringWithFormat:@"%@", dateString]; | |
| NSDate *realDate = [df dateFromString:date]; | |
| [df release]; | |
| return realDate; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment