How to add a number of weeks to an NSDate?

前端 未结 4 1625
一生所求
一生所求 2021-01-18 03:31

I have in the past used the below function to add on a specific time interval using NSDateComponents to an existing date.

(NSDate *)dateByAddin         


        
4条回答
  •  清酒与你
    2021-01-18 04:22

    I prefer to use dateByAddingUnit. It's more intuitive

    return [NSDate[[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitMonth value:3 toDate:toDate options:0];
    

提交回复
热议问题