date(from:)

Returns a date created from the specified components.

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
func date(from components: DateComponents) -> Date?

Parameters

components

Used as input to the search algorithm for finding a corresponding date.

Returns

A new Date, or nil if a date could not be found which matches the components.