DateComponents

DateComponents encapsulates the components of a date in an extendable, structured manner.

iOS
8.0+
macOS
10.9+
tvOS
9.0+
watchOS
2.0+
struct DateComponents

It is used to specify a date by providing the temporal components that make up a date and time in a particular calendar: hour, minutes, seconds, day, month, year, and so on. It can also be used to specify a duration of time, for example, 5 hours and 16 minutes. A DateComponents is not required to define all the component fields.

When a new instance of DateComponents is created, the date components are set to nil.