NSTimeZone is an abstract class that defines the behavior of time zone objects. Time zone objects represent geopolitical regions. Consequently, these objects have names for these regions. Time zone objects also represent a temporal offset, either plus or minus, from Greenwich Mean Time (GMT) and an abbreviation (such as PST for Pacific Standard Time).


NSTimeZone provides several class methods to get time zone objects: timeZoneWithName:, timeZoneWithName:data:, init(abbreviation:), and init(forSecondsFromGMT:). The class also permits you to set the default time zone within your application (setDefault(_:)). You can access this default time zone at any time with the default() class method, and with the local() class method, you can get a relative time zone object that decodes itself to become the default time zone for any locale in which it finds itself.

Note that, strictly, time zone database entries such as “America/Los_Angeles” are IDs not names. An example of a time zone name is “Pacific Daylight Time”. Although many NSTimeZone method names include the word “name”, they refer to IDs.

Cocoa does not provide any API to change the time zone of the computer, or of other applications.

NSTimeZone is “toll-free bridged” with its Core Foundation counterpart, CFTimeZone. See Toll-Free Bridging for more information on toll-free bridging.

Nested Types


Specify styles for presenting time zone names.


Creating and Initializing Time Zone Objects

init?(abbreviation: String)

Returns the time zone object identified by a given abbreviation.

init(forSecondsFromGMT: Int)

Returns a time zone object offset from Greenwich Mean Time by a given number of seconds.

init?(name: String)

Returns a time zone initialized with a given ID.

init?(name: String, data: Data?)

Initializes a time zone with a given ID and time zone data.

Working with System Time Zones

class func resetSystemTimeZone()

Resets the system time zone object cached by the application, if any.

Getting Information About a Specific Time Zone

var abbreviation: String?

The abbreviation for the receiver, such as “EDT” (Eastern Daylight Time).

func abbreviation(for: Date)

Returns the abbreviation for the receiver at a given date.

var name: String

The geopolitical region ID that identifies the receiver.

var secondsFromGMT: Int

The current difference in seconds between the receiver and Greenwich Mean Time.

func secondsFromGMT(for: Date)

Returns the difference in seconds between the receiver and Greenwich Mean Time at a given date.

var data: Data

The data that stores the information used by the receiver.

Comparing Time Zones

func isEqual(to: TimeZone)

Returns a Boolean value that indicates whether the receiver has the same name and data as the specified time zone.

Describing a Time Zone

var description: String

The description of the receiver, including the name, abbreviation, offset from GMT, and whether or not daylight saving time is currently in effect.

func localizedName(NSTimeZone.NameStyle, locale: Locale?)

Returns the name of the receiver localized for a given locale.

Getting Information About Daylight Saving

var isDaylightSavingTime: Bool

A Boolean value that indicates whether the receiver is currently using daylight saving time.

var daylightSavingTimeOffset: TimeInterval

The current daylight saving time offset of the receiver.

func isDaylightSavingTime(for: Date)

Returns a Boolean value that indicates whether the receiver uses daylight saving time at a given date.

func daylightSavingTimeOffset(for: Date)

Returns the daylight saving time offset for a given date.

var nextDaylightSavingTimeTransition: Date?

The date of the next daylight saving time transition for the receiver.

func nextDaylightSavingTimeTransition(after: Date)

Returns the next daylight saving time transition after a given date.



Specify styles for presenting time zone names.



Inherits From