0Pricing
Swift Academy · Lesson

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

  1. The Date Type and Time Intervals
  2. Calendar and DateComponents
  3. Formatting Dates
  4. Time Zones and Locales
← Back to Swift Academy