Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Forked from jeena/gist:579071
Created September 14, 2010 14:16
Show Gist options
  • Save tobiastom/579108 to your computer and use it in GitHub Desktop.
Save tobiastom/579108 to your computer and use it in GitHub Desktop.
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *thisDayComponents = [[NSDateComponents alloc] init];
[thisDayComponents setYear:2010];
[thisDayComponents setMonth:9];
[thisDayComponents setDay:1];
[thisDayComponents setCalendar:gregorian];
NSString *aDate = [[gregorian dateFromComponents:thisDayComponents] descriptionWithLocale:nil];
NSLog(@"day:%i date:%@", [thisDayComponents day], aDate);
// result => day:1 date:2010-09-01 00:00:00 +0200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment