TimeZoneInfo
TimeZoneInfo
TimeZoneInfo
TimeZoneInfo
Class
Definition
Represents any time zone in the world.
public ref class TimeZoneInfo sealed : IEquatable<TimeZoneInfo ^>, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class TimeZoneInfo : IEquatable<TimeZoneInfo>, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type TimeZoneInfo = class
interface IEquatable<TimeZoneInfo>
interface ISerializable
interface IDeserializationCallback
Public NotInheritable Class TimeZoneInfo
Implements IDeserializationCallback, IEquatable(Of TimeZoneInfo), ISerializable
- Inheritance
- Attributes
- Implements
Remarks
A time zone is a geographical region in which the same time is used.
The TimeZoneInfo class offers significant enhancements over the TimeZone class, which provides only limited functionality.
The TimeZone class recognizes only the local time zone, and can convert times between Coordinated Universal Time (UTC) and local time. A TimeZoneInfo object can represent any time zone, and methods of the TimeZoneInfo class can be used to convert the time in one time zone to the corresponding time in any other time zone. The members of the TimeZoneInfo class support the following operations:
Retrieving a time zone that is already defined by the operating system.
Enumerating the time zones that are available on a system.
Converting times between different time zones.
Creating a new time zone that is not already defined by the operating system.
Serializing a time zone for later retrieval.
Note
An instance of the TimeZoneInfo class is immutable. Once an object has been instantiated, its values cannot be modified.
You cannot instantiate a TimeZoneInfo object using the new keyword. Instead, you must call one of the static members of the TimeZoneInfo class shown in the following table.
| Static member name | Description |
|---|---|
| CreateCustomTimeZone method | Creates a custom time zone from application-supplied data. |
| FindSystemTimeZoneById method | Instantiates a time zone based on its identifier. |
| FromSerializedString method | Deserializes a string value to re-create a previously serialized TimeZoneInfo object. |
| GetSystemTimeZones method | Returns an enumerable ReadOnlyCollection<T> of TimeZoneInfo objects that represents all time zones that are available on the local system. |
| Local property | Instantiates a TimeZoneInfo object that represents the local time zone. |
| Utc property | Instantiates a TimeZoneInfo object that represents the UTC zone. |
You can use the CreateCustomTimeZone method to create a time zone that is not defined in the local system registry on Windows systems or by the time zone classes in the ICU Library on Linux or macOS. You can then use the ToSerializedString property to save the time zone object's information as a string, which can be stored in some form that is accessible to the application. You can use the FromSerializedString method to convert a serialized string back to a TimeZoneInfo object.
Properties
| BaseUtcOffset BaseUtcOffset BaseUtcOffset BaseUtcOffset |
Gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC). |
| DaylightName DaylightName DaylightName DaylightName |
Gets the display name for the current time zone's daylight saving time. |
| DisplayName DisplayName DisplayName DisplayName |
Gets the general display name that represents the time zone. |
| Id Id Id Id |
Gets the time zone identifier. |
| Local Local Local Local |
Gets a TimeZoneInfo object that represents the local time zone. |
| StandardName StandardName StandardName StandardName |
Gets the display name for the time zone's standard time. |
| SupportsDaylightSavingTime SupportsDaylightSavingTime SupportsDaylightSavingTime SupportsDaylightSavingTime |
Gets a value indicating whether the time zone has any daylight saving time rules. |
| Utc Utc Utc Utc |
Gets a TimeZoneInfo object that represents the Coordinated Universal Time (UTC) zone. |
Methods
Explicit Interface Implementations
| IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) |
Runs when the deserialization of an object has been completed. |
| ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) |
Populates a SerializationInfo object with the data needed to serialize the current TimeZoneInfo object. |