Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​TimeZoneInfo

Assembly: System.Runtime

Inheritance: object → TimeZoneInfo

Implemented Interfaces

Represents any time zone in the world.

Properties

public TimeSpan
BaseUtcOffset
Gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).
public string
DaylightName
Gets the display name for the current time zone's daylight saving time.
public string
DisplayName
Gets the general display name that represents the time zone.
public bool
HasIanaId
Returns <see langword="true" /> if this TimeZoneInfo object has an IANA ID.
public string
Id
Gets the time zone identifier.
public static TimeZoneInfo
Local
Gets a <see cref="T:System.TimeZoneInfo" /> object that represents the local time zone.
public string
StandardName
Gets the display name for the time zone's standard time.
public bool
SupportsDaylightSavingTime
Gets a value indicating whether the time zone has any daylight saving time rules.
public static TimeZoneInfo
Utc
Gets a <see cref="T:System.TimeZoneInfo" /> object that represents the Coordinated Universal Time (UTC) zone.

Methods

public static void
ClearCachedData​()
Clears cached time zone data.
public static DateTime
ConvertTime​(DateTime dateTime, TimeZoneInfo destinationTimeZone)
Converts a time to the time in a particular time zone.
Returns The date and time in the destination time zone.
dateTime The date and time to convert.
destinationTimeZone The time zone to convert <paramref name="dateTime" /> to.
public static DateTime
ConvertTime​(DateTime dateTime, TimeZoneInfo sourceTimeZone, TimeZoneInfo destinationTimeZone)
Converts a time from one time zone to another.
Returns The date and time in the destination time zone that corresponds to the <paramref name="dateTime" /> parameter in the source time zone.
dateTime The date and time to convert.
sourceTimeZone The time zone of <paramref name="dateTime" /> .
destinationTimeZone The time zone to convert <paramref name="dateTime" /> to.
public static DateTimeOffset
ConvertTime​(DateTimeOffset dateTimeOffset, TimeZoneInfo destinationTimeZone)
Converts a time to the time in a particular time zone.
Returns The date and time in the destination time zone.
dateTimeOffset The date and time to convert.
destinationTimeZone The time zone to convert <paramref name="dateTimeOffset" /> to.
public static DateTime
ConvertTimeBySystemTimeZoneId​(DateTime dateTime, string destinationTimeZoneId)
Converts a time to the time in another time zone based on the time zone's identifier.
Returns The date and time in the destination time zone.
dateTime The date and time to convert.
destinationTimeZoneId The identifier of the destination time zone.
public static DateTime
ConvertTimeBySystemTimeZoneId​(DateTime dateTime, string sourceTimeZoneId, string destinationTimeZoneId)
Converts a time from one time zone to another based on time zone identifiers.
Returns The date and time in the destination time zone that corresponds to the <paramref name="dateTime" /> parameter in the source time zone.
dateTime The date and time to convert.
sourceTimeZoneId The identifier of the source time zone.
destinationTimeZoneId The identifier of the destination time zone.
public static DateTimeOffset
ConvertTimeBySystemTimeZoneId​(DateTimeOffset dateTimeOffset, string destinationTimeZoneId)
Converts a time to the time in another time zone based on the time zone's identifier.
Returns The date and time in the destination time zone.
dateTimeOffset The date and time to convert.
destinationTimeZoneId The identifier of the destination time zone.
public static DateTime
ConvertTimeFromUtc​(DateTime dateTime, TimeZoneInfo destinationTimeZone)
Converts a Coordinated Universal Time (UTC) to the time in a specified time zone.
Returns The date and time in the destination time zone. Its <see cref="P:System.DateTime.Kind" /> property is <see cref="F:System.DateTimeKind.Utc" /> if <paramref name="destinationTimeZone" /> is <see cref="P:System.TimeZoneInfo.Utc" /> ; otherwise, its <see cref="P:System.DateTime.Kind" /> property is <see cref="F:System.DateTimeKind.Unspecified" /> .
dateTime The Coordinated Universal Time (UTC).
destinationTimeZone The time zone to convert <paramref name="dateTime" /> to.
public static DateTime
ConvertTimeToUtc​(DateTime dateTime)
Converts the specified date and time to Coordinated Universal Time (UTC).
Returns The Coordinated Universal Time (UTC) that corresponds to the <paramref name="dateTime" /> parameter. The <see cref="T:System.DateTime" /> value's <see cref="P:System.DateTime.Kind" /> property is always set to <see cref="F:System.DateTimeKind.Utc" /> .
dateTime The date and time to convert.
public static DateTime
ConvertTimeToUtc​(DateTime dateTime, TimeZoneInfo sourceTimeZone)
Converts the time in a specified time zone to Coordinated Universal Time (UTC).
Returns The Coordinated Universal Time (UTC) that corresponds to the <paramref name="dateTime" /> parameter. The <see cref="T:System.DateTime" /> object's <see cref="P:System.DateTime.Kind" /> property is always set to <see cref="F:System.DateTimeKind.Utc" /> .
dateTime The date and time to convert.
sourceTimeZone The time zone of <paramref name="dateTime" /> .
public static TimeZoneInfo
CreateCustomTimeZone​(string id, TimeSpan baseUtcOffset, string displayName, string standardDisplayName)
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.
Returns The new time zone.
id The time zone's identifier.
baseUtcOffset An object that represents the time difference between this time zone and Coordinated Universal Time (UTC).
displayName The display name of the new time zone.
standardDisplayName The name of the new time zone's standard time.
public static TimeZoneInfo
CreateCustomTimeZone​(string id, TimeSpan baseUtcOffset, string displayName, string standardDisplayName, string daylightDisplayName, AdjustmentRule[] adjustmentRules)
public static TimeZoneInfo
CreateCustomTimeZone​(string id, TimeSpan baseUtcOffset, string displayName, string standardDisplayName, string daylightDisplayName, AdjustmentRule[] adjustmentRules, bool disableDaylightSavingTime)
public bool
Equals​(object obj)
Determines whether the current <see cref="T:System.TimeZoneInfo" /> object and another object are equal.
Returns <see langword="true" /> if <paramref name="obj" /> is a <see cref="T:System.TimeZoneInfo" /> object that is equal to the current instance; otherwise, <see langword="false" /> .
obj A second object to compare with the current object.
public bool
Equals​(TimeZoneInfo other)
Determines whether the current <see cref="T:System.TimeZoneInfo" /> object and another <see cref="T:System.TimeZoneInfo" /> object are equal.
Returns <see langword="true" /> if the two <see cref="T:System.TimeZoneInfo" /> objects are equal; otherwise, <see langword="false" /> .
other A second object to compare with the current object.
public static TimeZoneInfo
FindSystemTimeZoneById​(string id)
Returns a <see cref="T:System.TimeZoneInfo" /> object based on its identifier.
Returns An object whose identifier is the value of the <paramref name="id" /> parameter.
id The time zone identifier, which corresponds to the <see cref="P:System.TimeZoneInfo.Id" /> property.
public static TimeZoneInfo
FromSerializedString​(string source)
Deserializes a string to re-create an original serialized <see cref="T:System.TimeZoneInfo" /> object.
Returns The original serialized object.
source The string representation of the serialized <see cref="T:System.TimeZoneInfo" /> object.
public AdjustmentRule[]
GetAdjustmentRules​()
Retrieves an array of <see cref="T:System.TimeZoneInfo.AdjustmentRule" /> objects that apply to the current <see cref="T:System.TimeZoneInfo" /> object.
Returns An array of objects for this time zone.
public TimeSpan[]
GetAmbiguousTimeOffsets​(DateTime dateTime)
Returns information about the possible dates and times that an ambiguous date and time can be mapped to.
Returns An array of objects that represents possible Coordinated Universal Time (UTC) offsets that a particular date and time can be mapped to.
dateTime A date and time.
public TimeSpan[]
GetAmbiguousTimeOffsets​(DateTimeOffset dateTimeOffset)
Returns information about the possible dates and times that an ambiguous date and time can be mapped to.
Returns An array of objects that represents possible Coordinated Universal Time (UTC) offsets that a particular date and time can be mapped to.
dateTimeOffset A date and time.
public int
GetHashCode​()
Serves as a hash function for hashing algorithms and data structures such as hash tables.
Returns A 32-bit signed integer that serves as the hash code for this <see cref="T:System.TimeZoneInfo" /> object.
public static ReadOnlyCollection<​TimeZoneInfo>
GetSystemTimeZones​()
Returns a sorted collection of all the time zones about which information is available on the local system.
Returns A read-only collection of <see cref="T:System.TimeZoneInfo" /> objects.
public static ReadOnlyCollection<​TimeZoneInfo>
GetSystemTimeZones​(bool skipSorting)
Returns a <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1" /> containing all valid TimeZone's from the local machine. This method does not throw TimeZoneNotFoundException or InvalidTimeZoneException.
skipSorting If <see langword="true" /> , The collection returned may not necessarily be sorted.
public TimeSpan
GetUtcOffset​(DateTime dateTime)
Calculates the offset or difference between the time in this time zone and Coordinated Universal Time (UTC) for a particular date and time.
Returns An object that indicates the time difference between the two time zones.
dateTime The date and time to determine the offset for.
public TimeSpan
GetUtcOffset​(DateTimeOffset dateTimeOffset)
Calculates the offset or difference between the time in this time zone and Coordinated Universal Time (UTC) for a particular date and time.
Returns An object that indicates the time difference between Coordinated Universal Time (UTC) and the current time zone.
dateTimeOffset The date and time to determine the offset for.
public bool
HasSameRules​(TimeZoneInfo other)
Indicates whether the current object and another <see cref="T:System.TimeZoneInfo" /> object have the same adjustment rules.
Returns <see langword="true" /> if the two time zones have identical adjustment rules and an identical base offset; otherwise, <see langword="false" /> .
other A second object to compare with the current <see cref="T:System.TimeZoneInfo" /> object.
public bool
IsAmbiguousTime​(DateTime 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.
Returns <see langword="true" /> if the <paramref name="dateTime" /> parameter is ambiguous; otherwise, <see langword="false" /> .
dateTime A date and time value.
public bool
IsAmbiguousTime​(DateTimeOffset 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.
Returns <see langword="true" /> if the <paramref name="dateTimeOffset" /> parameter is ambiguous in the current time zone; otherwise, <see langword="false" /> .
dateTimeOffset A date and time.
public bool
IsDaylightSavingTime​(DateTime dateTime)
Indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current <see cref="T:System.TimeZoneInfo" /> object.
Returns <see langword="true" /> if the <paramref name="dateTime" /> parameter is a daylight saving time; otherwise, <see langword="false" /> .
dateTime A date and time value.
public bool
IsDaylightSavingTime​(DateTimeOffset dateTimeOffset)
Indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current <see cref="T:System.TimeZoneInfo" /> object.
Returns <see langword="true" /> if the <paramref name="dateTimeOffset" /> parameter is a daylight saving time; otherwise, <see langword="false" /> .
dateTimeOffset A date and time value.
public bool
IsInvalidTime​(DateTime dateTime)
Indicates whether a particular date and time is invalid.
Returns <see langword="true" /> if <paramref name="dateTime" /> is invalid; otherwise, <see langword="false" /> .
dateTime A date and time value.
public string
ToSerializedString​()
Converts the current <see cref="T:System.TimeZoneInfo" /> object to a serialized string.
Returns A string that represents the current <see cref="T:System.TimeZoneInfo" /> object.
public string
ToString​()
Returns the current <see cref="T:System.TimeZoneInfo" /> object's display name.
Returns The value of the <see cref="P:System.TimeZoneInfo.DisplayName" /> property of the current <see cref="T:System.TimeZoneInfo" /> object.
public static bool
TryConvertIanaIdToWindowsId​(string ianaId, String&? windowsId)
public static bool
TryConvertWindowsIdToIanaId​(string windowsId, string region, String& ianaId)
public static bool
TryConvertWindowsIdToIanaId​(string windowsId, String&? ianaId)
public static bool
TryFindSystemTimeZoneById​(string id, TimeZoneInfo&? timeZoneInfo)
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .