Export (0) Print
Expand All

TimeZoneInfo.ConvertTime Method (DateTimeOffset, TimeZoneInfo)

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.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft