Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The TimeZoneInfo class does not expose a public constructor. As a result, the new
keyword cannot be used to create a new TimeZoneInfo object. Instead, TimeZoneInfo objects are instantiated either by retrieving information on predefined time zones from the registry or by creating a custom time zone. This topic discusses instantiating a time zone from data stored in the registry. In addition, static
(shared
in Visual Basic) properties of the TimeZoneInfo class provide access to Coordinated Universal Time (UTC) and the local time zone.
Note
For time zones that are not defined in the registry, you can create custom time zones by calling the overloads of the CreateCustomTimeZone method. Creating a custom time zone is discussed in the How to: Create time zones without adjustment rules and How to: Create time zones with adjustment rules topics. In addition, you can instantiate a TimeZoneInfo object by restoring it from a serialized string with the FromSerializedString method. Serializing and deserializing a TimeZoneInfo object is discussed in the How to: Save time zones to an embedded resource and How to: Restore Time Zones from an Embedded Resource topics.
The TimeZoneInfo class provides two predefined time zone objects that represent the UTC time and the local time zone. They are available from the Utc and Local properties, respectively. For instructions on accessing the UTC or local time zones, see How to: Access the predefined UTC and local time zone objects.
You can also instantiate a TimeZoneInfo object that represents any time zone defined in the registry. For instructions on instantiating a specific time zone object, see How to: Instantiate a TimeZoneInfo object.
The time zone identifier is a key field that uniquely identifies the time zone. While most keys are relatively short, the time zone identifier is comparatively long. In most cases, its value corresponds to the TimeZoneInfo.StandardName property, which is used to provide the name of the time zone's standard time. However, there are exceptions. The best way to make sure that you supply a valid identifier is to enumerate the time zones available on your system and note their associated identifiers.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Get started with classes and objects in C# - Training
Learn how to create classes and instantiate objects that expose encapsulated field data by using class definitions, constructors, and the 'new' operator.