Export (0) Print
Expand All

DateTimeOffset.UtcDateTime Property

Gets a DateTime value that represents the Coordinated Universal Time (UTC) date and time of the current DateTimeOffset object.

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

public DateTime UtcDateTime { get; }

Property Value

Type: System.DateTime
The Coordinated Universal Time (UTC) date and time of the current DateTimeOffset object.

The UtcDateTime property performs a dual conversion:

  • It converts the date and time of the current DateTimeOffset object to Coordinated Universal Time (UTC). The conversion is performed by subtracting the value of the Offset property from the date and time of the current DateTimeOffset object.

  • It converts the DateTimeOffset value to a DateTime value.

The Kind property of the returned DateTime value is set to DateTimeKind.Utc.

Retrieving the value of the UtcDateTime property is equivalent to calling the current DateTimeOffset object's ToUniversalTime.DateTime property, except that the Kind property of the latter DateTime value is DateTimeKind.Unspecified.

The following example shows how to use of the UtcDateTime property to display a DateTimeOffset value and its corresponding UTC time.

DateTimeOffset offsetTime = new DateTimeOffset(2007, 11, 25, 11, 14, 00, 
                            new TimeSpan(3, 0, 0));
Console.WriteLine("{0} is equivalent to {1} {2}", 
// The example displays the following output: 
//       11/25/2007 11:14:00 AM +03:00 is equivalent to 11/25/2007 8:14:00 AM Utc      

.NET Framework

Supported in: 4.5, 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft