DateTimeOffset Constructor (Int64, TimeSpan)

 

Initializes a new instance of the DateTimeOffset structure using the specified number of ticks and offset.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
DateTimeOffset(
	long long ticks,
	TimeSpan offset
)

Parameters

ticks
Type: System::Int64

A date and time expressed as the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight on January 1, 0001.

offset
Type: System::TimeSpan

The time's offset from Coordinated Universal Time (UTC).

Exception Condition
ArgumentException

offset is not specified in whole minutes.

ArgumentOutOfRangeException

The UtcDateTime property is earlier than MinValue or later than MaxValue.

-or-

ticks is less than DateTimeOffset.MinValue.Ticks or greater than DateTimeOffset.MaxValue.Ticks.

-or-

Offset s less than -14 hours or greater than 14 hours.

Ordinarily, trying to call the DateTimeOffset constructor to instantiate a DateTimeOffset value with a local time and an offset other than that of the local time zone throws an ArgumentException. You can use this overload of the DateTimeOffset constructor to work around this limitation. The following example uses the local time's number of ticks to instantiate a DateTimeOffset value whose offset does not necessarily represent that of the local time:

No code example is currently available or this language may not be supported.

The following example initializes a DateTimeOffset object by using the number of ticks in an arbitrary date (in this case, July 16, 2007, at 1:32 PM) with an offset of -5.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: