Represents any time zone in the world.
Namespace:
System
Assembly:
System.Core (in System.Core.dll)
Visual Basic (Declaration)
<SerializableAttribute> _
<HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort := True)> _
Public NotInheritable Class TimeZoneInfo _
Implements IEquatable(Of TimeZoneInfo), ISerializable, _
IDeserializationCallback
Dim instance As TimeZoneInfo
[SerializableAttribute]
[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
public sealed class TimeZoneInfo : IEquatable<TimeZoneInfo>,
ISerializable, IDeserializationCallback
[SerializableAttribute]
[HostProtectionAttribute(SecurityAction::LinkDemand, MayLeakOnAbort = true)]
public ref class TimeZoneInfo sealed : IEquatable<TimeZoneInfo^>,
ISerializable, IDeserializationCallback
public final class TimeZoneInfo implements IEquatable<TimeZoneInfo>, ISerializable, IDeserializationCallback
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 defined in the system registry based on the zone's identifier. |
FromSerializedString method | Deserializes a string value to re-create a previously serialized TimeZoneInfo object. |
GetSystemTimeZones method | Returns an enumerable ReadOnlyCollection<(Of <(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. 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.
System..::.Object
System..::.TimeZoneInfo
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5
Reference
Other Resources