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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.