Instance Method

component:fromDate:

Returns the specified date component from a given date.

Declaration

- (NSInteger)component:(NSCalendarUnit)unit fromDate:(NSDate *)date;

Parameters

unit

The component to return. For possible values, see NSCalendarUnit.

date

The date for which to perform the calculation.

Return Value

An NSInteger value for the requested component.

See Also

Extracting Components

- date:matchesComponents:

Returns whether a given date matches all of the given date components.

- components:fromDate:

Returns the date components representing a given date.

- components:fromDate:toDate:options:

Returns the difference between two supplied dates as date components.

- components:fromDateComponents:toDateComponents:options:

Returns the difference between start and end dates given as date components.

- componentsInTimeZone:fromDate:

Returns all the date components of a date, as if in a given time zone (instead of the receiving calendar’s time zone).

- getEra:year:month:day:fromDate:

Returns by reference the era, year, week of year, and weekday component values for a given date.

- getEra:yearForWeekOfYear:weekOfYear:weekday:fromDate:

Returns by reference the era, year, week of year, and weekday component values for a given date.

- getHour:minute:second:nanosecond:fromDate:

Returns by reference the hour, minute, second, and nanosecond component values for a given date.