开发者

Get date of date + value Objective C

开发者 https://www.devze.com 2023-02-22 20:43 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消