DateTimeOffset.UtcNow 속성

정의

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

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밀리초입니다.

적용 대상

추가 정보