How To Add Month To NSDate Object?
NSDate *someDate = [NSDate Date] + 30Days.....;
To add more days to a current date object, you can use the Calendar and the DateComponents() Swift structs. let currentDate = Date() var dateComponent = DateComponents() dateComponent. day = 1 let futureDate = Calendar.
Component, value: Int) -> Date { let noon = Calendar. current. date(bySettingHour: 12, minute: 0, second: 0, of: self)! return Calendar.
You need to use NSDateComponents:
NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; [dateComponents setMonth:1]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:originalDate options:0]; [dateComponents release]; // If ARC is not used, release the date components
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With