How to add one month to an NSDate?

前端 未结 9 2158
自闭症患者
自闭症患者 2020-12-23 11:01

How To Add Month To NSDate Object?

NSDate *someDate = [NSDate Date] + 30Days.....;
9条回答
  •  情深已故
    2020-12-23 11:34

    In Swift 2.0

        let startDate = NSDate()
        let dateComponent = NSDateComponents()
        dateComponent.month = 1
        let cal = NSCalendar.currentCalendar()
        let endDate = cal.dateByAddingComponents(dateComponent, toDate: startDate, options: NSCalendarOptions(rawValue: 0))
    

提交回复
热议问题