TimeZoneInfo Class

 

Represents any time zone in the world.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

System.Object
  System.TimeZoneInfo

[SerializableAttribute]
[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
public sealed class TimeZoneInfo : IEquatable<TimeZoneInfo>, 
	ISerializable, IDeserializationCallback

NameDescription
System_CAPS_pubpropertyBaseUtcOffset

Gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).

System_CAPS_pubpropertyDaylightName

Gets the display name for the current time zone's daylight saving time.

System_CAPS_pubpropertyDisplayName

Gets the general display name that represents the time zone.

System_CAPS_pubpropertyId

Gets the time zone identifier.

System_CAPS_pubpropertySystem_CAPS_staticLocal

Gets a TimeZoneInfo object that represents the local time zone.

System_CAPS_pubpropertyStandardName

Gets the display name for the time zone's standard time.

System_CAPS_pubpropertySupportsDaylightSavingTime

Gets a value indicating whether the time zone has any daylight saving time rules.

System_CAPS_pubpropertySystem_CAPS_staticUtc

Gets a TimeZoneInfo object that represents the Coordinated Universal Time (UTC) zone.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticClearCachedData()

Clears cached time zone data.

System_CAPS_pubmethodSystem_CAPS_staticConvertTime(DateTime, TimeZoneInfo)

Converts a time to the time in a particular time zone.

System_CAPS_pubmethodSystem_CAPS_staticConvertTime(DateTime, TimeZoneInfo, TimeZoneInfo)

Converts a time from one time zone to another.

System_CAPS_pubmethodSystem_CAPS_staticConvertTime(DateTimeOffset, TimeZoneInfo)

Converts a time to the time in a particular time zone.

System_CAPS_pubmethodSystem_CAPS_staticConvertTimeBySystemTimeZoneId(DateTime, String)

Converts a time to the time in another time zone based on the time zone's identifier.

System_CAPS_pubmethodSystem_CAPS_staticConvertTimeBySystemTimeZoneId(DateTime, String, String)

Converts a time from one time zone to another based on time zone identifiers.

System_CAPS_pubmethodSystem_CAPS_staticConvertTimeBySystemTimeZoneId(DateTimeOffset, String)

Converts a time to the time in another time zone based on the time zone's identifier.

System_CAPS_pubmethodSystem_CAPS_staticConvertTimeFromUtc(DateTime, TimeZoneInfo)

Converts a Coordinated Universal Time (UTC) to the time in a specified time zone.

System_CAPS_pubmethodSystem_CAPS_staticConvertTimeToUtc(DateTime)

Converts the specified date and time to Coordinated Universal Time (UTC).

System_CAPS_pubmethodSystem_CAPS_staticConvertTimeToUtc(DateTime, TimeZoneInfo)

Converts the time in a specified time zone to Coordinated Universal Time (UTC).

System_CAPS_pubmethodSystem_CAPS_staticCreateCustomTimeZone(String, TimeSpan, String, String)

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, and a standard time display name.

System_CAPS_pubmethodSystem_CAPS_staticCreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo.AdjustmentRule[])

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, and daylight saving time rules.

System_CAPS_pubmethodSystem_CAPS_staticCreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo.AdjustmentRule[], Boolean)

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, daylight saving time rules, and a value that indicates whether the returned object reflects daylight saving time information.

System_CAPS_pubmethodEquals(Object)

Determines whether the current TimeZoneInfo object and another object are equal.(Overrides Object.Equals(Object).)

System_CAPS_pubmethodEquals(TimeZoneInfo)

Determines whether the current TimeZoneInfo object and another TimeZoneInfo object are equal.

System_CAPS_pubmethodSystem_CAPS_staticFindSystemTimeZoneById(String)

Retrieves a TimeZoneInfo object from the registry based on its identifier.

System_CAPS_pubmethodSystem_CAPS_staticFromSerializedString(String)

Deserializes a string to re-create an original serialized TimeZoneInfo object.

System_CAPS_pubmethodGetAdjustmentRules()

Retrieves an array of TimeZoneInfo.AdjustmentRule objects that apply to the current TimeZoneInfo object.

System_CAPS_pubmethodGetAmbiguousTimeOffsets(DateTime)

Returns information about the possible dates and times that an ambiguous date and time can be mapped to.

System_CAPS_pubmethodGetAmbiguousTimeOffsets(DateTimeOffset)

Returns information about the possible dates and times that an ambiguous date and time can be mapped to.

System_CAPS_pubmethodGetHashCode()

Serves as a hash function for hashing algorithms and data structures such as hash tables.(Overrides Object.GetHashCode().)

System_CAPS_pubmethodSystem_CAPS_staticGetSystemTimeZones()

Returns a sorted collection of all the time zones about which information is available on the local system.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetUtcOffset(DateTime)

Calculates the offset or difference between the time in this time zone and Coordinated Universal Time (UTC) for a particular date and time.

System_CAPS_pubmethodGetUtcOffset(DateTimeOffset)

Calculates the offset or difference between the time in this time zone and Coordinated Universal Time (UTC) for a particular date and time.

System_CAPS_pubmethodHasSameRules(TimeZoneInfo)

Indicates whether the current object and another TimeZoneInfo object have the same adjustment rules.

System_CAPS_pubmethodIsAmbiguousTime(DateTime)

Determines whether a particular date and time in a particular time zone is ambiguous and can be mapped to two or more Coordinated Universal Time (UTC) times.

System_CAPS_pubmethodIsAmbiguousTime(DateTimeOffset)

Determines whether a particular date and time in a particular time zone is ambiguous and can be mapped to two or more Coordinated Universal Time (UTC) times.

System_CAPS_pubmethodIsDaylightSavingTime(DateTime)

Indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current TimeZoneInfo object.

System_CAPS_pubmethodIsDaylightSavingTime(DateTimeOffset)

Indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current TimeZoneInfo object.

System_CAPS_pubmethodIsInvalidTime(DateTime)

Indicates whether a particular date and time is invalid.

System_CAPS_pubmethodToSerializedString()

Converts the current TimeZoneInfo object to a serialized string.

System_CAPS_pubmethodToString()

Returns the current TimeZoneInfo object's display name.(Overrides Object.ToString().)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDeserializationCallback.OnDeserialization(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Runs when the deserialization of an object has been completed.

System_CAPS_pubinterfaceSystem_CAPS_privmethodISerializable.GetObjectData(SerializationInfo, StreamingContext)

This API supports the product infrastructure and is not intended to be used directly from your code. Populates a SerializationInfo object with the data needed to serialize the current TimeZoneInfo object.

A time zone is a geographical region in which the same time is used.

TheTimeZoneInfo 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.

System_CAPS_noteNote

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<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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: