One Logo Pool Ball
Foundation · IOS API REFERENCE

Date.FormatStyle.Symbol.TimeZone

struct · iOS 15.0+ · SDK 27.1

struct TimeZone

A type that specifies a format for the time zone in a date format style. The type ``Date/FormatStyle/Symbol/TimeZone`` includes static factory variables and methods that create custom ``Date/FormatStyle/Symbol/TimeZone`` objects: |Factory variable|Description| |---|---| | ``specificName(_:)`` | The specific, non-location representation of a timezone. For example, `CDT` (`short`), `Central Daylight Time` (`long`). | | ``genericName(_:)`` | The generic, non-location representation of a timezone. For example, `CT` (`short`), `Central Time` (`long`). | | ``iso8601(_:)`` | The ISO 8601 representation of the timezone with hours, minutes, and optional seconds. For example, `-0500` (`short`), `-05:00` (`long`). | | ``localizedGMT(_:)`` | The localized GMT format representation of a timezone. For example, `GMT-5` (`short`), `GMT-05:00` (`long`). | | ``identifier(_:)`` | The timezone identifier. For example, `uschi` (`short`), `America/Chicago` (`long`). | | ``exemplarLocation`` | The exemplar city for a timezone. For example, `Chicago`. | | ``genericLocation`` | The generic location representation of a timezone. For example, `Chicago Time`. | To customize the hour format in a string representation of a `Date`, use ``Date/FormatStyle/timeZone(_:)``. The following example shows a variety of ``Date/FormatStyle/Symbol/TimeZone`` format styles applied to a date. ```swift let meetingDate = Date() // Feb 9, 2021 at 7:00 PM meetingDate.formatted(Date.FormatStyle().timeZone(.specificName(.short))) // CDT meetingDate.formatted(Date.FormatStyle().timeZone(.specificName(.long))) // Central Daylight Time meetingDate.formatted(Date.FormatStyle().timeZone(.genericName(.short))) // CT meetingDate.formatted(Date.FormatStyle().timeZone(.genericName(.long))) // Central Time meetingDate.formatted(Date.FormatStyle().timeZone(.iso8601(.short))) // -0500 meetingDate.formatted(Date.FormatStyle().timeZone(.iso8601(.long))) // -05:00 meetingDate.formatted(Date.FormatStyle().timeZone(.localizedGMT(.short))) // GMT-5 meetingDate.formatted(Date.FormatStyle().timeZone(.localizedGMT(.long))) // GMT-05:00 meetingDate.formatted(Date.FormatStyle().timeZone(.identifier(.short))) // uschi meetingDate.formatted(Date.FormatStyle().timeZone(.identifier(.long))) // America/Chicago meetingDate.formatted(Date.FormatStyle().timeZone(.exemplarLocation)) // Chicago meetingDate.formatted(Date.FormatStyle().timeZone(.genericLocation)) // Chicago Time ``` If you don't provide a format, the system formats a timezone using the short ``specificName(_:)`` static function with the width ``Width/short``. For more information about formatting dates, see the ``Date/FormatStyle``.

Members (8)

static · iOS 15.0+

identifier

TypeScript
static identifier(width: Date_FormatStyle_Symbol_TimeZone_Width): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static func identifier(_ width: Date.FormatStyle.Symbol.TimeZone.Width) -> Date.FormatStyle.Symbol.TimeZone

The time zone ID. For example, short: "uslax" long: "America/Los_Angeles".

static · iOS 15.0+

genericName

TypeScript
static genericName(width: Date_FormatStyle_Symbol_TimeZone_Width): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static func genericName(_ width: Date.FormatStyle.Symbol.TimeZone.Width) -> Date.FormatStyle.Symbol.TimeZone

Generic non-location format. Falls back to `genericLocation` if unavailable. For example, short: "PT". Fallback again to `localizedGMT(.short)` if `genericLocation(.short)` is unavailable. long: "Pacific Time"

static · iOS 15.0+

localizedGMT

TypeScript
static localizedGMT(width: Date_FormatStyle_Symbol_TimeZone_Width): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static func localizedGMT(_ width: Date.FormatStyle.Symbol.TimeZone.Width) -> Date.FormatStyle.Symbol.TimeZone

Short localized GMT format. For example, short: "GMT-8" long: "GMT-8:00"

static · iOS 15.0+

specificName

TypeScript
static specificName(width: Date_FormatStyle_Symbol_TimeZone_Width): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static func specificName(_ width: Date.FormatStyle.Symbol.TimeZone.Width) -> Date.FormatStyle.Symbol.TimeZone

Specific non-location format. Falls back to `shortLocalizedGMT` if unavailable. For example, short: "PDT" long: "Pacific Daylight Time".

get · iOS 15.0+

genericLocation

TypeScript
static get genericLocation(): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static var genericLocation: Date.FormatStyle.Symbol.TimeZone { get }

The generic location format. Falls back to `longLocalizedGMT` if unavailable. Recommends for presenting possible time zone choices for user selection. For example, "Los Angeles Time".

get · iOS 15.0+

exemplarLocation

TypeScript
static get exemplarLocation(): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static var exemplarLocation: Date.FormatStyle.Symbol.TimeZone { get }

The exemplar city (location) for the time zone. The localized exemplar city name for the special zone or unknown is used as the fallback if it is unavailable. For example, "Los Angeles".

static · iOS 15.0+

iso8601

TypeScript
static iso8601(width: Date_FormatStyle_Symbol_TimeZone_Width): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static func iso8601(_ width: Date.FormatStyle.Symbol.TimeZone.Width) -> Date.FormatStyle.Symbol.TimeZone

The ISO8601 format with hours, minutes and optional seconds fields. For example, short: "-0800" long: "-08:00" or "-07:52:58".

get · iOS 18.0+

omitted

TypeScript
static get omitted(): Date_FormatStyle_Symbol_TimeZone
Swift declaration
static let omitted: Date.FormatStyle.Symbol.TimeZone

The option for not including the symbol in the formatted output.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →