You want to use NSCalendar and NSDateComponents to accomplish what you need. Something like the following should do the trick.
NSDate *todaysDate = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setYear:1];
NSDate *targetDate = [gregorian dateByAddingComponents:dateComponents toDate:todaysDate options:0];
[dateComponents release];
[gregorian release];
To then output the target date as a string in the specified format, you can do the following:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString* dateString = [dateFormatter stringFromDate:targetDate];
Hope this helps.
source
share