Commonly Used Date Methods
The following sections list some of the most commonly used methods of NSCalendarDate, grouped according to function. Creating Dates
The methods in this section are class methods, denoted by the plus sign (+). You use class methods to send messages to a class-in this case, NSCalendarDate. For more information on class methods, see "Sending a Message to a Class".
- + calendarDate
- Returns an NSCalendarDate initialized to the current date and time.
- + dateWithString:calendarFormat:
- Returns an NSCalendarDate initialized to the date in a provided string, and sets the new NSCalendarDate's calendar format to the specified format. The date string must match the provided format exactly. See "Date Conversion Specifiers" for more detailed information on formats used by NSCalendarDate.
Adjusting a Date
- - dateByAddingYears:months:days:hours:minutes:seconds:
- Returns an NSCalendarDate derived from the receiver by adding a specified number of years, months, days, hours, minutes, and seconds.
Representing Dates as Strings
- - description
- Returns a string representation of the NSCalendarDate formatted according to the NSCalendarDate's default calendar format.
- - descriptionWithCalendarFormat:
- Returns a string representation of the receiver formatted according to the provided format string.
- - calendarFormat
- Returns a string that indicates the receiver's default calendar format. See "Date Conversion Specifiers" for more detailed information on formats used by NSCalendarDate.
- - setCalendarFormat:
- Set the receiver's default calendar format to the provided string.
Retrieving Date Elements
- - dayOfWeek
- Returns a number that indicates the NSCalendarDate's day of the week (0-6).
- - dayOfMonth
- Returns the NSCalendarDate's day of the month (1-31).
- - dayOfYear
- Returns a number that indicates the NSCalendarDate's day of the year (1-366).
- - dayOfCommonEra
- Returns the NSCalendarDate's number of days since the beginning of the Common Era. The base year of the Common Era is 1 A.C.E. (which is the same as 1 A.D.).
- - monthOfYear
- Returns a number that indicates the NSCalendarDate's month of the year (1-12).
- - yearOfCommonEra
- Returns the NSCalendarDate's year value (including the century).
- - hourOfDay
- Returns the NSCalendarDate's hour value (0-23).
- - minuteOfHour
- Returns the NSCalendarDate's minutes value (0-59).
- - secondOfMinute
- Returns the NSCalendarDate's seconds value (0-59).