DateTimeOffset.Ticks 속성

정의

클럭 시간으로 현재 DateTimeOffset 개체의 날짜와 시간을 나타내는 틱 수를 가져옵니다.

public:
 property long Ticks { long get(); };
public long Ticks { get; }
member this.Ticks : int64
Public ReadOnly Property Ticks As Long

속성 값

DateTimeOffset 개체에 대한 클록 시간의 틱 수입니다.

예제

다음 예제에서는 2008년 7월 1일 1:23:07 날짜의 틱 수를 근사화하여 개체를 초기화 DateTimeOffset 합니다. 그런 다음, 해당 날짜로 표시되는 날짜 및 틱 수를 콘솔에 표시합니다.

// Attempt to initialize date to number of ticks
// in July 1, 2008 1:23:07.
//
// There are 10,000,000 100-nanosecond intervals in a second
const long NSPerSecond = 10000000;
long ticks;
ticks = 7 * NSPerSecond;                        // Ticks in a 7 seconds
ticks += 23 * 60 * NSPerSecond;                 // Ticks in 23 minutes
ticks += 1 * 60 * 60 * NSPerSecond;             // Ticks in 1 hour
ticks += 60 * 60 * 24 * NSPerSecond;            // Ticks in 1 day
ticks += 181 * 60 * 60 * 24 * NSPerSecond;      // Ticks in 6 months
ticks += 2007 * 60 * 60 * 24 * 365L * NSPerSecond;   // Ticks in 2007 years
ticks += 486 * 60 * 60 * 24 * NSPerSecond;      // Adjustment for leap years
DateTimeOffset dto = new DateTimeOffset(
                         ticks,
                         DateTimeOffset.Now.Offset);
Console.WriteLine("There are {0:n0} ticks in {1}.",
                  dto.Ticks,
                  dto.ToString());
// The example displays the following output:
//       There are 633,504,721,870,000,000 ticks in 7/1/2008 1:23:07 AM -08:00.
// Attempt to initialize date to number of ticks
// in July 1, 2008 1:23:07.
//
// There are 10,000,000 100-nanosecond intervals in a second
let NSPerSecond = 10000000L
let ticks = 7L * NSPerSecond                                  // Ticks in a 7 seconds
let ticks = ticks + 23L * 60L * NSPerSecond                   // Ticks in 23 minutes
let ticks = ticks + 1L * 60L * 60L * NSPerSecond              // Ticks in 1 hour
let ticks = ticks + 60L * 60L * 24L * NSPerSecond             // Ticks in 1 day
let ticks = ticks + 181L * 60L * 60L * 24L * NSPerSecond      // Ticks in 6 months
let ticks = ticks + 2007L * 60L * 60L * 24L * 365L * NSPerSecond   // Ticks in 2007 years
let ticks = ticks + 486L * 60L * 60L * 24L * NSPerSecond      // Adjustment for leap years
let dto = DateTimeOffset(ticks, DateTimeOffset.Now.Offset)
printfn $"There are {ticks:n0} ticks in {dto}."

// The example displays the following output:
//       There are 633,504,721,870,000,000 ticks in 7/1/2008 1:23:07 AM -08:00.
' Attempt to initialize date to number of ticks
' in July 1, 2008 1:23:07.      
'
' There are 10,000,000 100-nanosecond intervals in a second
Const NSPerSecond As Long = 10000000
Dim ticks As Long
ticks = 7 * NSPerSecond                         ' Ticks in a 7 seconds 
ticks += 23 * 60 * NSPerSecond                  ' Ticks in 23 minutes
ticks += 1 * 60 * 60 * NSPerSecond              ' Ticks in 1 hour
ticks += 60 * 60 * 24 * NSPerSecond             ' Ticks in 1 day
ticks += 181 * 60 * 60 * 24 * NSPerSecond       ' Ticks in 6 months 
ticks += 2007 * 60 * 60 * 24 * 365l * NSPerSecond   ' Ticks in 2007 years 
ticks += 486 * 60 * 60 * 24 * NSPerSecond       ' Adjustment for leap years      
Dim dto As DateTimeOffset = New DateTimeOffset( _
                            ticks, _
                            DateTimeOffset.Now.Offset)
Console.WriteLine("There are {0:n0} ticks in {1}.", _
                  dto.Ticks, _
                  dto.ToString())
' The example displays the following output:
'       There are 633,504,721,870,000,000 ticks in 7/1/2008 1:23:07 AM -08:00.

설명

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

속성 값 Ticks 은 0001년 1월 1일 자정 12:00:00(값) 이후 경과된 100나노초 간격의 MinValue수를 나타냅니다. 윤초별로 추가되는 틱은 포함되지 않습니다. 나노초는 10억 초입니다. 초당 1,000만 개의 틱이 있습니다. 속성의 Ticks 값은 에서 DateTimeOffset.MinValue.TicksDateTimeOffset.MaxValue.Ticks로 범위가 지정됩니다.

생성자 오버로드를 DateTimeOffset 사용하여 개체에 틱 수를 할당할 DateTimeOffset(Int64, TimeSpan) 수 있습니다.

적용 대상

추가 정보