NSTimeZone
Information about standard time conventions associated with a specific geopolitical region.
Declaration
class NSTimeZoneOverview
In Swift, this type bridges to TimeZone; use NSTimeZone when you need reference semantics or other Foundation-specific behavior.
Time zones represent the standard time policies for a geopolitical region. Time zones have identifiers like “America/Los_Angeles” and can also be identified by abbreviations, such as PST for Pacific Standard Time. You can create time zone objects by ID with init(name:) and by abbreviation with init(abbreviation:).
Time zones can also represent a temporal offset—either plus or minus—from Greenwich Mean Time (GMT). For example, the temporal offset of Pacific Standard Time is 8 hours behind Greenwich Mean Time (GMT-8). You can create time zone objects with a temporal offset by using init(forSecondsFromGMT:).
You typically work with system time zones rather than creating time zones by identifier or by offset. The system class property returns the time zone currently used by the system, if known. This value is cached once the property is accessed and doesn’t reflect any system time zone changes until you call the resetSystemTimeZone() method. The local class property returns an autoupdating proxy object that always returns the current time zone used by the system. You can also set the default class property to make your app run as if it were in a different time zone than the system.
NSTimeZone is toll-free bridged with its Core Foundation counterpart, CFTimeZone. See Toll-Free Bridging for more information on toll-free bridging.
Topics
Working with System Time Zones
Creating Time Zones
init(name:)init(name:data:)init(abbreviation:)init(forSecondsFromGMT:)knownTimeZoneNamesabbreviationDictionary
Getting Time Zone Information
nameabbreviationabbreviation(for:)secondsFromGMTsecondsFromGMT(for:)datatimeZoneDataVersionNSTimeZone.NameStyle
Working with Daylight Savings
isDaylightSavingTimeisDaylightSavingTime(for:)daylightSavingTimeOffsetdaylightSavingTimeOffset(for:)nextDaylightSavingTimeTransitionnextDaylightSavingTimeTransition(after:)