TimeZoneInfo.ConvertTime Method (DateTimeOffset, TimeZoneInfo)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Converts a time to the time in a particular time zone.
Assembly: mscorlib (in mscorlib.dll)
public static DateTimeOffset ConvertTime( DateTimeOffset dateTimeOffset, TimeZoneInfo destinationTimeZone )
- Type: System.DateTimeOffset
The date and time to convert.
The value of the destinationTimeZone parameter is null.
When performing the conversion, the method applies any adjustment rules in effect in the destinationTimeZone time zone.
This overload differs from the other overloads of the ConvertTime method by accepting a DateTimeOffset value as its first parameter. This identifies the date and time as an offset from Coordinated Universal Time (UTC) rather than as the date and time in a particular time zone. As a result, the dateTimeOffset parameter cannot represent either an ambiguous time or an invalid time.
In converting the dateTimeOffset value to the time in the destination time zone, this 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.
XNA FrameworkWhen this method is used in the XNA Framework, it throws a NotSupportedException exception.