DateTimeOffset.UtcDateTime 属性     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 DateTime 值,该值表示当前 DateTimeOffset 对象的协调世界时 (UTC) 日期和时间。
public:
 property DateTime UtcDateTime { DateTime get(); };public DateTime UtcDateTime { get; }member this.UtcDateTime : DateTimePublic ReadOnly Property UtcDateTime As DateTime属性值
当前 DateTimeOffset 对象的协调世界时 (UTC) 日期和时间。
示例
下面的示例演示如何使用该 UtcDateTime 属性显示 DateTimeOffset 值及其相应的 UTC 时间。
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
let offsetTime = DateTimeOffset(2007, 11, 25, 11, 14, 00, TimeSpan(3, 0, 0))
printfn $"{offsetTime} is equivalent to {offsetTime.UtcDateTime} {offsetTime.UtcDateTime.Kind}"
// 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
注解
该 UtcDateTime 属性执行双重转换:
- 它将当前 DateTimeOffset 对象的日期和时间转换为协调世界时 (UTC) 。 转换是通过从当前DateTimeOffset对象的日期和时间中减去属性的值Offset来执行的。 
- 它将值转换为 DateTimeOffset 值 DateTime 。 
Kind返回DateTime的值的属性设置为 DateTimeKind.Utc。
检索属性的值 UtcDateTime 等效于调用当前 DateTimeOffset 对象的 ToUniversalTime.DateTime 属性,但 Kind 后一 DateTime 个值的属性除外 DateTimeKind.Unspecified。