This document describes how to handle date and time data using Cocoa.
You should read this document if your application keeps track of dates and times, particularly if it compares and manipulates elapsed time and points in time, such as calendar dates.
This document contains three articles and one appendix:
“Dates” describes the NSDate class, which represents dates and times in Cocoa. It explains how to create date objects and how to perform date-based calculations.
“Calendars, Date Components, and Calendar Units” describes the basic features of the NSCalendar class.
“Calendrical Calculations” describes the basic features of the NSDateComponents class and explains how to create calendars and perform calendrical computations, including getting the component elements of dates.
“Using Time Zones” explains the behavior of time zone objects defined by the NSTimeZone class.
“Legacy API: NSCalendarDate” provides information about the class that represents a Gregorian calendar, NSCalendarDate. This class does not exist in iPhone OS and is deprecated in Mac OS X. All of the capabilities of NSCalendarDate are duplicated by other, recommended classes, as described in the other articles of this document.
Data Formatting Programming Guide for Cocoa explains how to create and format user-readable strings from date objects, and how to create date objects from formatted strings.
Last updated: 2009-07-21