DateTimeOffset.DateTime 속성

정의

현재 DateTimeOffset 개체의 날짜와 시간을 나타내는 DateTime 값을 가져옵니다.

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

속성 값

DateTime

현재 DateTimeOffset 개체의 날짜와 시간입니다.

예제

다음 예제에서는 속성에서 DateTime 반환 Now UtcNow 된 시간과 속성을 값으로 변환하는 데 사용하는 방법을 DateTime 보여 줍니다.

DateTimeOffset offsetDate;
DateTime regularDate;

offsetDate = DateTimeOffset.Now;
regularDate = offsetDate.DateTime;
Console.WriteLine("{0} converts to {1}, Kind {2}.",
                  offsetDate.ToString(),
                  regularDate,
                  regularDate.Kind);

offsetDate = DateTimeOffset.UtcNow;
regularDate = offsetDate.DateTime;
Console.WriteLine("{0} converts to {1}, Kind {2}.",
                  offsetDate.ToString(),
                  regularDate,
                  regularDate.Kind);
// If run on 3/6/2007 at 17:11, produces the following output:
//
//   3/6/2007 5:11:22 PM -08:00 converts to 3/6/2007 5:11:22 PM, Kind Unspecified.
//   3/7/2007 1:11:22 AM +00:00 converts to 3/7/2007 1:11:22 AM, Kind Unspecified.
let offsetDate = DateTimeOffset.Now
let regularDate = offsetDate.DateTime
printfn $"{offsetDate} converts to {regularDate}, Kind {regularDate.Kind}."

let offsetDate = DateTimeOffset.UtcNow
let regularDate = offsetDate.DateTime
printfn $"{offsetDate} converts to {regularDate}, Kind {regularDate.Kind}."

// If run on 3/6/2007 at 17:11, produces the following output:
//
//   3/6/2007 5:11:22 PM -08:00 converts to 3/6/2007 5:11:22 PM, Kind Unspecified.
//   3/7/2007 1:11:22 AM +00:00 converts to 3/7/2007 1:11:22 AM, Kind Unspecified.
Dim offsetDate As DateTimeOffset 
Dim regularDate As Date

offsetDate = DateTimeOffset.Now
regularDate = offsetDate.DateTime
Console.WriteLine("{0} converts to {1}, Kind {2}.", _
                  offsetDate.ToString(), _
                  regularDate, _ 
                  regularDate.Kind)
               
offsetDate = DateTimeOffset.UtcNow
regularDate = offsetDate.DateTime
Console.WriteLine("{0} converts to {1}, Kind {2}.", _
                  offsetDate.ToString(), _
                  regularDate, _
                  regularDate.Kind)
' If run on 3/6/2007 at 17:11, produces the following output:
'
'   3/6/2007 5:11:22 PM -08:00 converts to 3/6/2007 5:11:22 PM, Kind Unspecified.
'   3/7/2007 1:11:22 AM +00:00 converts to 3/7/2007 1:11:22 AM, Kind Unspecified.

설명

속성은 DateTime 속성 값의 Offset 영향을 받지 않습니다.

이 속성은 개체의 DateTimeOffset 날짜 및 시간 구성 요소를 모두 반환하므로 변환을 수행하는 DateTimeOffset DateTime 데 유용합니다. 예를 들어 개체의 DateTimeOffset 날짜 및 시간 값이 "1/12/07 4:01pm + 7:30"인 경우 속성은 "1/12/07 4:01pm" 날짜를 반환합니다.

반환 DateTime 된 개체의 DateTime.Kind 속성 값은 .입니다DateTimeKind.Unspecified.

적용 대상

추가 정보