Class

ISO8601DateFormatter

A formatter that converts between dates and their IOS 8601 string representations.

Overview

The ISO8601DateFormatter class generates and parses string representations of dates following the ISO 8601 standard. Use this class to create ISO 8601 representations of dates and create dates from text strings in ISO 8601 format.

Topics

Configuring the Formatter

var formatOptions: ISO8601DateFormatter.Options

Options for generating and parsing ISO 8601 date representations. See ISO8601DateFormatter.Options for possible values.

var timeZone: TimeZone!

The time zone used to create and parse date representations. When unspecified, GMT is used.

Creating ISO 8601 Date Formatters

init()

Initializes an ISO 8601 date formatter with default format, time zone, and options.

Converting ISO 8601 Dates

func string(from: Date)

Creates and returns an ISO 8601 formatted string representation of the specified date.

func date(from: String)

Creates and returns a date object from the specified ISO 8601 formatted string representation.

class func string(from: Date, timeZone: TimeZone, formatOptions: ISO8601DateFormatter.Options = [])

Creates a representation of the specified date with a given time zone and format options.

Constants

struct ISO8601DateFormatter.Options

Options used to generate and parse ISO 8601 date representations.

Relationships

Inherits From

See Also

Date Formatting

class DateFormatter

A formatter that converts between dates and their textual representations.

class DateComponentsFormatter

A formatter that creates string representations of quantities of time.

class DateIntervalFormatter

A formatter that creates string representations of time intervals.