Created
July 26, 2012 11:20
-
-
Save diederikh/3181541 to your computer and use it in GitHub Desktop.
31th Jan + 1 Month
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
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDateComponents *comp = [NSDateComponents new]; | |
comp.day = 31; | |
comp.month = 1; | |
comp.year = 2012; | |
NSDateComponents *addMonthComp = [NSDateComponents new]; | |
addMonthComp.month = 1; | |
NSLog(@"31th Jan + 1 month: %@",[cal dateByAddingComponents:addMonthComp toDate:[cal dateFromComponents:comp] options:0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output:
2012-07-26 13:19:48.320 Untitled[81574:707] 31th Jan + 1 month: 2012-02-28 23:00:00 +0000