This topic has not yet been rated - Rate this topic

TimeZoneInfo.ConvertTime Method (DateTimeOffset, TimeZoneInfo)

April 12, 2014

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

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
public static DateTimeOffset ConvertTime(
	DateTimeOffset dateTimeOffset,
	TimeZoneInfo destinationTimeZone
)

Parameters

dateTimeOffset
Type: System.DateTimeOffset
The date and time to convert.
destinationTimeZone
Type: System.TimeZoneInfo
The time zone to convert dateTime to. It must be either TimeZoneInfo.Local or TimeZoneInfo.Utc.

Return Value

Type: System.DateTimeOffset
A DateTimeOffset value that represents the date and time in the destination time zone.
ExceptionCondition
ArgumentNullException

The value of the destinationTimeZone parameter is null.

When performing the conversion, the ConvertTime(DateTimeOffset, TimeZoneInfo) 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.

Version Notes

XNA Framework

 When this method is used in the XNA Framework, it throws a NotSupportedException exception.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.