Created
December 6, 2013 13:11
-
-
Save ariok/7823545 to your computer and use it in GitHub Desktop.
Adding some months to an existent date.//
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
+ (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