Skip to content

Instantly share code, notes, and snippets.

@tudormunteanu
Created August 15, 2012 12:11
Show Gist options
  • Select an option

  • Save tudormunteanu/3359590 to your computer and use it in GitHub Desktop.

Select an option

Save tudormunteanu/3359590 to your computer and use it in GitHub Desktop.
NSDate and NSDateFormatter
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