且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在iOS中添加当前日期的一天

更新时间:2023-11-30 12:38:10

表示您要添加到原始日期的天数的日期组件。从当前日历表格的日期通过添加此组件到您的原始日期。

Form a date component with number of days you want to add to your original date. From the current calendar form the date by adding the this component to your original date.

NSDateComponents *dateComponents = [NSDateComponents new];
dateComponents.day = 1;
NSDate *newDate = [[NSCalendar currentCalendar]dateByAddingComponents:dateComponents 
                                                               toDate: selectedDate 
                                                              options:0];