DateTimeOffset.Ticks DateTimeOffset.Ticks DateTimeOffset.Ticks DateTimeOffset.Ticks Property

定義

日付を表すタイマー刻みの数と、現在の時刻を取得DateTimeOffsetオブジェクトのクロック時間。Gets the number of ticks that represents the date and time of the current DateTimeOffset object in clock time.

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

プロパティ値

タイマー刻みの数、DateTimeOffsetオブジェクトのクロック時間。The number of ticks in the DateTimeOffset object's clock time.

次の例では、初期化、DateTimeOffsetオブジェクト、2008 年 7 月 1 日のおおよそのタイマー刻みの数を 1時 23分: 07 します。The following example initializes a DateTimeOffset object by approximating the number of ticks in the date July 1, 2008 1:23:07. 日時をコンソールにその日付で表されたタイマー刻みの数が表示されます。It then displays the date and the number of ticks represented by that date to the console.

// 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
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プロパティ。The Ticks property is not affected by the value of the Offset property.

値、Ticksプロパティは 0001 年 1 月 1 日 12時 00分: 00 の午前 0 時以降の経過時間を 100 ナノ秒間隔の数を表します (の値MinValue)。The value of the Ticks property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight on January 1, 0001 (the value of MinValue). これは、タイマー刻みうるう秒によって追加されるには含まれません。It does not include ticks that would be added by leap seconds. ナノ秒は、10億分の秒です。1 秒あたり 10億のタイマー刻みがあります。A nanosecond is one billionth of a second; there are ten million ticks in a second. 値、Ticksプロパティの範囲はDateTimeOffset.MinValue.TicksDateTimeOffset.MaxValue.Ticksします。The value of the Ticks property ranges from DateTimeOffset.MinValue.Ticks to DateTimeOffset.MaxValue.Ticks.

タイマー刻みの数を割り当てることができます、DateTimeOffsetオブジェクトを使用して、DateTimeOffset(Int64, TimeSpan)コンス トラクター オーバー ロードします。You can assign the number of ticks to a DateTimeOffset object by using the DateTimeOffset(Int64, TimeSpan) constructor overload.

適用対象

こちらもご覧ください