Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TimeZoneInfo::ConvertTimeFromUtc Method (DateTime, TimeZoneInfo^)

 

Converts a Coordinated Universal Time (UTC) to the time in a specified time zone.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
static DateTime ConvertTimeFromUtc(
	DateTime dateTime,
	TimeZoneInfo^ destinationTimeZone
)

Parameters

dateTime
Type: System::DateTime

The Coordinated Universal Time (UTC).

destinationTimeZone
Type: System::TimeZoneInfo^

The time zone to convert dateTime to.

Return Value

Type: System::DateTime

The date and time in the destination time zone. Its DateTime::Kind property is DateTimeKind::Utc if destinationTimeZone is TimeZoneInfo::Utc; otherwise, its DateTime::Kind property is DateTimeKind::Unspecified.

Exception Condition
ArgumentException

The Kind property of dateTime is DateTimeKind::Local.

ArgumentNullException

destinationTimeZone is null.

When performing the conversion, the ConvertTimeFromUtc method applies any adjustment rules in effect in the destinationTimeZone time zone.

The precise behavior of this method depends on the value of the Kind property of the dateTime parameter, as the following table shows.

DateTime.Kind property

Conversion

DateTimeKind::Local

Throws an ArgumentException.

DateTimeKind::Unspecified or DateTimeKind::Utc

Converts from Coordinated Universal Time (UTC).

If the conversion of dateTime results in a date and time value that is earlier than DateTime::MinValue or later than DateTime::MaxValue, this method returns DateTime::MinValue or DateTime::MaxValue, respectively.

Notes to Callers:

On Windows XP systems, this method applies only the current adjustment rule to the time zone conversion if destinationTimeZone is TimeZoneInfo::Local. As a result, the method may not accurately convert times for periods before the current adjustment rule came into effect. For more information, see the Notes for Callers section in the Local property.

The following example converts Coordinated Universal Time (UTC) to Central Time.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.5
Return to top
Show:
© 2017 Microsoft