DateTimeOffset.UtcDateTime Propiedad

Definición

Obtiene un valor DateTime que representa la fecha y hora de la hora universal coordinada (UTC) del objeto DateTimeOffset actual.Gets a DateTime value that represents the Coordinated Universal Time (UTC) date and time of the current DateTimeOffset object.

public:
 property DateTime UtcDateTime { DateTime get(); };
public DateTime UtcDateTime { get; }
member this.UtcDateTime : DateTime
Public ReadOnly Property UtcDateTime As DateTime

Valor de propiedad

DateTime

Fecha y hora en hora universal coordinada (UTC) del objeto DateTimeOffset actual.The Coordinated Universal Time (UTC) date and time of the current DateTimeOffset object.

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar la UtcDateTime propiedad para mostrar un DateTimeOffset valor y su hora UTC correspondiente.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}",
                  offsetTime.ToString(),
                  offsetTime.UtcDateTime.ToString(),
                  offsetTime.UtcDateTime.Kind.ToString());
// 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
Dim offsetTime As New DateTimeOffset(#11/25/2007 11:14AM#, _
                  New TimeSpan(3, 0, 0))
Console.WriteLine("{0} is equivalent to {1} {2}", _
                  offsetTime.ToString(), _
                  offsetTime.UtcDateTime.ToString(), _
                  offsetTime.UtcDateTime.Kind.ToString())      
' 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      

Comentarios

La UtcDateTime propiedad realiza una conversión dual:The UtcDateTime property performs a dual conversion:

  • Convierte la fecha y hora del objeto actual en la DateTimeOffset hora universal coordinada (UTC).It converts the date and time of the current DateTimeOffset object to Coordinated Universal Time (UTC). La conversión se realiza restando el valor de la Offset propiedad de la fecha y hora del DateTimeOffset objeto actual.The conversion is performed by subtracting the value of the Offset property from the date and time of the current DateTimeOffset object.

  • Convierte el DateTimeOffset valor en un DateTime valor.It converts the DateTimeOffset value to a DateTime value.

La Kind propiedad del valor devuelto DateTime se establece en DateTimeKind.Utc .The Kind property of the returned DateTime value is set to DateTimeKind.Utc.

La recuperación del valor de la UtcDateTime propiedad es equivalente a llamar a la DateTimeOffset propiedad del objeto actual ToUniversalTime.DateTime , salvo que la Kind propiedad del último DateTime valor es DateTimeKind.Unspecified .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.

Se aplica a