The Date Type and Time Intervals
Represent points in time and durations.
The Date Type
Foundation's Date represents a single point in time, independent of any calendar or time zone. Internally it is a number of seconds relative to a reference date.
Creating a Date
Date() gives the current instant. Every call returns the moment it executes.
import Foundation
let now = Date()
print("Now is a Date value")
print(type(of: now))All lessons in this course
- The Date Type and Time Intervals
- Calendar and DateComponents
- Formatting Dates
- Time Zones and Locales