DateTimeOffset.UtcNow Özellik

Tanım

Tarih ve saati geçerli Eşgüdümlü Evrensel Saat (UTC) tarih ve saat olarak ayarlanmış ve uzaklığı olan Zerobir DateTimeOffset nesneyi alır.

public:
 static property DateTimeOffset UtcNow { DateTimeOffset get(); };
public static DateTimeOffset UtcNow { get; }
static member UtcNow : DateTimeOffset
Public Shared ReadOnly Property UtcNow As DateTimeOffset

Özellik Değeri

Tarih ve saati geçerli Eşgüdümlü Evrensel Saat (UTC) olan ve uzaklığı olan bir nesne.Zero

Örnekler

Aşağıdaki örnekte Eşgüdümlü Evrensel Saat (UTC) ile yerel saat arasındaki ilişki gösterilmektedir.

DateTimeOffset localTime = DateTimeOffset.Now;
DateTimeOffset utcTime = DateTimeOffset.UtcNow;

Console.WriteLine("Local Time:          {0}", localTime.ToString("T"));
Console.WriteLine("Difference from UTC: {0}", localTime.Offset.ToString());
Console.WriteLine("UTC:                 {0}", utcTime.ToString("T"));
// If run on a particular date at 1:19 PM, the example produces
// the following output:
//    Local Time:          1:19:43 PM
//    Difference from UTC: -07:00:00
//    UTC:                 8:19:43 PM
let localTime = DateTimeOffset.Now
let utcTime = DateTimeOffset.UtcNow

printfn $"Local Time:          {localTime:T}"
printfn $"Difference from UTC: {localTime.Offset}"
printfn $"UTC:                 {utcTime:T}"

// If run on a particular date at 1:19 PM, the example produces
// the following output:
//    Local Time:          1:19:43 PM
//    Difference from UTC: -07:00:00
//    UTC:                 8:19:43 PM
Dim localTime As DateTimeOffset = DateTimeOffset.Now
Dim utcTime As DateTimeOffset = DateTimeOffset.UtcNow

Console.WriteLine("Local Time:          {0}", localTime.ToString("T"))
Console.WriteLine("Difference from UTC: {0}", localTime.Offset.ToString())
Console.WriteLine("UTC:                 {0}", utcTime.ToString("T"))
' If run on a particular date at 1:19 PM, the example produces
' the following output:
'    Local Time:          1:19:43 PM
'    Difference from UTC: -07:00:00
'    UTC:                 8:19:43 PM

Açıklamalar

özelliği, UtcNow yerel sistemin saat saatini ve yerel sistemin saat dilimi tarafından tanımlanan uzaklığını temel alarak geçerli Evrensel Eşgüdümlü Saati (UTC) hesaplar.

Geçerli UTC saatinin milisaniyelik bileşeninin duyarlığı, sistem saatinin çözünürlüğüne bağlıdır. Windows NT 3.5 ve üzeri sürümlerde ve Windows Vista işletim sistemlerinde saatin çözünürlüğü yaklaşık 10-15 milisaniyedir.

Şunlara uygulanır

Ayrıca bkz.