I would like to get a date from an amount of months plus a date.
as an example.
I would like the output to be:
start date: 4th april
amount of months: 5
output date: 4th september
Is there any code to do this?
开发者_运维知识库Thanks
If you have a read of Apple's Date and Time Programming Guide there are a few solutions that should present themselves.
For example, you could create a base NSDate and then use the NSCalendar dateByAddingComponents:toDate:options:
method to add the relevant number of months as a component.
If you're after some clean sample source code, see the "Adding Components to a Date" section within the Calendrical Calculations section of the above programming guide.
Yes there is, have a look at Apple's Date and Time Programming Guide.
精彩评论