DateTimeOffset.Offset 속성

정의

UTC(협정 세계시)를 기준으로 한 해당 시간의 오프셋을 가져옵니다.

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

속성 값

TimeSpan

현재 DateTimeOffset 개체의 시간 값과 UTC(협정 세계시) 사이의 차이입니다.

예제

다음 예제에서는 이 속성을 사용하여 Offset UTC(협정 세계시)와 현지 시간의 차이를 표시합니다.

DateTimeOffset localTime = DateTimeOffset.Now;
Console.WriteLine("The local time zone is {0} hours and {1} minutes {2} than UTC.",
                  Math.Abs(localTime.Offset.Hours),
                  localTime.Offset.Minutes,
                  localTime.Offset.Hours < 0 ? "earlier" : "later");
// The example displays output similar to the following for a system in the
// U.S. Pacific Standard Time zone:
//       The local time zone is 8 hours and 0 minutes earlier than UTC.
let localTime = DateTimeOffset.Now        
printfn $"""The local time zone is {abs localTime.Offset.Hours} hours and {localTime.Offset.Minutes} minutes {if localTime.Offset.Hours < 0 then "earlier" else "later"} than UTC."""

// The example displays output similar to the following for a system in the
// U.S. Pacific Standard Time zone:
//       The local time zone is 8 hours and 0 minutes earlier than UTC.
Dim localTime As DateTimeOffset = DateTimeOffset.Now
Console.WriteLine("The local time zone is {0} hours and {1} minutes {2} than UTC.", _
                  Math.Abs(localTime.Offset.Hours), _
                  localTime.Offset.Minutes, _
                  IIf(localTime.Offset.Hours < 0, "earlier", "later"))
' If run on a system whose local time zone is U.S. Pacific Standard Time,
' the example displays output similar to the following:
'       The local time zone is 8 hours and 0 minutes earlier than UTC.

설명

반환 TimeSpan 된 개체의 Hours 속성 값은 -14시간에서 14시간까지입니다.

속성 값 Offset 은 분 단위로 정확합니다.

적용 대상