component(_:from:)

Returns the value for one component of a date.

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
func component(_ component: Calendar.Component, from date: Date) -> Int

Parameters

component

The component to calculate.

date

The date to use.

Returns

The value for the component.