How do I add 1 day to an NSDate?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
To add one calendar day to an NSDate, use Calendar or NSCalendar, not raw second arithmetic. Adding 86400 seconds looks tempting, but it can be wrong around daylight saving time transitions and calendar boundaries. Date arithmetic should be calendar-aware.
The Modern Swift Approach
In Swift, the modern type is Date, which bridges with NSDate. The usual solution is Calendar.current.date(byAdding:value:to:).
This asks the calendar to add one day as a calendar component, which is exactly what you want for user-facing date logic.
Why Not Add 86400 Seconds?
A day is not always exactly 86400 seconds in local calendar terms. Daylight saving time changes can create shorter or longer local days.
This approach is risky:
It adds a fixed amount of elapsed time, not a calendar day. If the user's timezone crosses a DST boundary between the two dates, the local clock result may be off by an hour relative to the intended calendar date.
For timers and elapsed durations, fixed seconds can be correct. For "tomorrow" in calendar logic, use Calendar.
Working with NSDate
If your code still uses NSDate, the same idea applies because Swift bridges NSDate and Date.
This is common in older codebases that still expose Objective-C APIs or legacy Foundation types.
Objective-C Style with NSCalendar
In Objective-C or older Foundation code, use NSCalendar and NSDateComponents.
This is the same idea in older API style: add one calendar day, not a fixed second offset.
Time Zones and User Expectations
Calendar arithmetic depends on the calendar and timezone in use. That is usually what you want, because the user expects "add one day" to follow their local calendar.
If your logic must use a specific timezone, configure the calendar explicitly.
This matters in server code, synchronization logic, and apps where date calculations must be consistent across regions rather than tied to the current user settings.
Start-of-Day Logic Is a Different Requirement
Sometimes "add one day" really means "move to the next calendar day at midnight." That is a slightly different operation.
If you skip that distinction, it is easy to accidentally preserve the original time-of-day when the actual requirement was "next day at the beginning of the day."
Common Pitfalls
The most common mistake is adding 86400 seconds and assuming that means "one day" in every calendar context. Another is forgetting which timezone the calculation should use, especially in apps that mix user-local display logic with server or UTC logic. Developers also sometimes work with NSDate in older code and forget that the recommended arithmetic still belongs in Calendar or NSCalendar, not in the date object itself.
Summary
- Add one day with
Calendar.date(byAdding:value:to:)or the Objective-CNSCalendarequivalent. - Do not use
86400seconds for user-facing calendar logic. - '
Dateis the modern Swift type, but the same approach works with bridgedNSDate.' - Set the calendar timezone explicitly when business rules require it.
- If you need the next day at midnight, combine day addition with
startOfDay.

