다음을 통해 공유


DateTimeOffset.UtcNow 속성

정의

DateTimeOffset 날짜와 시간이 현재 UTC(협정 세계시) 날짜 및 시간으로 설정되고 오프셋Zero이 있는 개체를 가져옵니다.

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

속성 값

날짜와 시간이 현재 UTC(협정 세계시)이고 오프셋이 있는 개체입니다 Zero.

예제

다음 예제에서는 UTC(협정 세계시)와 현지 시간 간의 관계를 보여 줍니다.

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

설명

이 속성은 UtcNow 로컬 시스템의 시계 시간과 로컬 시스템의 표준 시간대에 정의된 오프셋을 기반으로 현재 UTC(유니버설 조정 시간)를 계산합니다.

현재 UTC 시간(밀리초) 구성 요소의 정밀도는 시스템 클록의 해상도에 따라 달라집니다. Windows NT 3.5 이상 및 Windows Vista 운영 체제에서 시계의 해상도는 약 10-15밀리초입니다.

적용 대상

추가 정보