TimeZoneInfo.ConvertTimeBySystemTimeZoneId Method (DateTimeOffset, String)
Converts a time to the time in another time zone based on the time zone's identifier.
Assembly: mscorlib (in mscorlib.dll)
static member ConvertTimeBySystemTimeZoneId : dateTimeOffset:DateTimeOffset * destinationTimeZoneId:string -> DateTimeOffset
- Type: System.DateTimeOffset
The date and time to convert.
- Type: System.String
The identifier of the destination time zone.
Return ValueType: System.DateTimeOffset
The date and time in the destination time zone.
destinationTimeZoneId is a null reference (Nothing in Visual Basic).
The time zone identifier was found but the registry data is corrupted.
The process does not have the permissions required to read from the registry key that contains the time zone information.
The destinationTimeZoneId identifier was not found on the local system.
When performing the conversion, the ConvertTimeBySystemTimeZoneId method applies any adjustment rules in effect in the destinationTimeZoneId time zone.
This overload is identical to calling the ConvertTime(DateTime, TimeZoneInfo) method, except that it allows you to specify the destination time zone by its identifier rather than by an object reference. This method is most useful when you must convert a time without retrieving the time zone object that corresponds to it and you do not need to know whether the converted time is standard or daylight saving time.
Because the dateTimeOffset parameter represents a date and time together with that time's offset from Coordinated Universal Time (UTC), it cannot represent either an ambiguous time or an invalid time.
This method retrieves the time zone whose identifier is specified by the destinationTimeZoneId parameter from the registry. It cannot retrieve a time zone object that is created using the CreateCustomTimeZone method. The destinationTimeZoneId parameter must correspond exactly to the time zone's registry key in length, but not in case, for a successful match to occur; that is, the comparison of destinationTimeZoneId with time zone identifiers is case-insensitive.
In converting the dateTimeOffset value to the time in the destination time zone, the method takes into account any adjustment rules in effect in the destination time zone.
If the conversion of dateTimeOffset results in a date and time value that is earlier than DateTimeOffset.MinValue or later than DateTimeOffset.MaxValue, this method returns DateTimeOffset.MinValue or DateTimeOffset.MaxValue, respectively.