UtcDateTime Property

DateTimeOffset.UtcDateTime Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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
An object whose value represents 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));
outputBlock.Text += String.Format("{0} is equivalent to {1} {2}",
                  offsetTime.ToString(),
                  offsetTime.UtcDateTime.ToString(),
                  offsetTime.UtcDateTime.Kind.ToString()) + "\n";


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft