DateTime.Ticks DateTime.Ticks DateTime.Ticks DateTime.Ticks Property

定義

このインスタンスの日付と時刻を表すタイマー刻み数を取得します。Gets the number of ticks that represent the date and time of this instance.

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

プロパティ値

このインスタンスの日付と時刻を表すタイマー刻み数。The number of ticks that represent the date and time of this instance. 値は DateTime.MinValue.Ticks から DateTime.MaxValue.Ticks までの間にあります。The value is between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.

次の例では、Ticksプロパティは、21 世紀の開始以降に経過したタイマー刻みの数が表示され、インスタンス化する、TimeSpanオブジェクト。The following example uses the Ticks property to display the number of ticks that have elapsed since the beginning of the twenty-first century and to instantiate a TimeSpan object. TimeSpan他のいくつかの時間間隔を使用した経過時間を表示するオブジェクトを使用しています。The TimeSpan object is then used to display the elapsed time using several other time intervals.

DateTime centuryBegin = new DateTime(2001, 1, 1);
DateTime currentDate = DateTime.Now;

long elapsedTicks = currentDate.Ticks - centuryBegin.Ticks;
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);

Console.WriteLine("Elapsed from the beginning of the century to {0:f}:", 
                   currentDate);
Console.WriteLine("   {0:N0} nanoseconds", elapsedTicks * 100);
Console.WriteLine("   {0:N0} ticks", elapsedTicks);
Console.WriteLine("   {0:N2} seconds", elapsedSpan.TotalSeconds);
Console.WriteLine("   {0:N2} minutes", elapsedSpan.TotalMinutes);
Console.WriteLine("   {0:N0} days, {1} hours, {2} minutes, {3} seconds", 
                  elapsedSpan.Days, elapsedSpan.Hours, 
                  elapsedSpan.Minutes, elapsedSpan.Seconds);
// If run on December 14, 2007, at 15:23, this example displays the
// following output to the console:
//    Elapsed from the beginning of the century to Friday, December 14, 2007 3:23 PM:
//          219,338,580,000,000,000 nanoseconds
//          2,193,385,800,000,000 ticks
//          219,338,580.00 seconds
//          3,655,643.00 minutes
//          2,538 days, 15 hours, 23 minutes, 0 seconds
Dim centuryBegin As Date = #1/1/2001 0:0:0#
Dim currentDate As Date = Date.Now
Dim elapsedTicks As Long = currentDate.Ticks - centuryBegin.Ticks
Dim elapsedSpan As New TimeSpan(elapsedTicks)

Console.WriteLine("Elapsed from the beginning of the century to {0:f}:", _
                   currentDate)
Console.WriteLine("   {0:N0} nanoseconds", elapsedTicks * 100)
Console.WriteLine("   {0:N0} ticks", elapsedTicks)
Console.WriteLine("   {0:N2} seconds", elapsedSpan.TotalSeconds)
Console.WriteLine("   {0:N2} minutes", elapsedSpan.TotalMinutes)
Console.WriteLine("   {0:N0} days, {1} hours, {2} minutes, {3} seconds", _
                  elapsedSpan.Days, elapsedSpan.Hours, _
                  elapsedSpan.Minutes, elapsedSpan.Seconds)
' If run on December 14, 2007, at 15:23, this example displays the
' following output to the console:
'          219,338,580,000,000,000 nanoseconds
'          2,193,385,800,000,000 ticks
'          219,338,580.00 seconds
'          3,655,643.00 minutes
'          2,538 days, 15 hours, 23 minutes, 0 seconds

注釈

単一のティックは 100 ナノ秒または 1 つ 10 分の 1 秒を表します。A single tick represents one hundred nanoseconds or one ten-millionth of a second. 10,000 ティックをミリ秒単位でまたは 1 秒あたり 10,000, 000 個のタイマー刻みがあります。There are 10,000 ticks in a millisecond, or 10 million ticks in a second.

このプロパティの値が 0001 年 1 月 1 日午前 12時 00分: 00 以降の経過時間を 100 ナノ秒間隔の数を表します (0: 00:00 年 1 月 1 日 UTC 0001、グレゴリオ暦で) を表すDateTime.MinValueします。The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 (0:00:00 UTC on January 1, 0001, in the Gregorian calendar), which represents DateTime.MinValue. 秒数を大きく前進に起因するタイマー刻みの数は含まれません。It does not include the number of ticks that are attributable to leap seconds.

適用対象