Skip to content

Instantly share code, notes, and snippets.

@ariok
Created December 6, 2013 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariok/7823545 to your computer and use it in GitHub Desktop.
Save ariok/7823545 to your computer and use it in GitHub Desktop.
Adding some months to an existent date.//
+ (NSDate*)dateAddingMonths:(NSInteger)months{
NSDateComponents* dateComponents = [[NSDateComponents alloc]init];
[dateComponents setMonth:months];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDate* newDate = [calendar dateByAddingComponents:dateComponents toDate:self options:0]; //NSDate category
return newDate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment