Skip to main content

NSDate addition using NSCalendar

If you have an NSDate and want to add a time unit onto that date, then an option is to use the NSCalendar.

This will allow you to add to the date via the dateByAddingUnit, which allows you to add an NSCalendarUnit. These units could be for example: hours, days, months,  years, minutes.

Once you decide what unit type you want to add, you then set the value as an integer and the toDate date you want apply the calculation to.

To add an hour of time to an NSDate:

 

Please follow and like us: