DateTimeOffset.Subtract Method (DateTimeOffset)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Subtracts a DateTimeOffset value that represents a specific date and time from the current DateTimeOffset object.

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

member Subtract : 
        value:DateTimeOffset -> TimeSpan

Parameters

value
Type: System.DateTimeOffset

An object that represents the value to subtract.

Return Value

Type: System.TimeSpan

An object that specifies the interval between the two DateTimeOffset objects.

This method converts both DateTimeOffset objects to Coordinated Universal Time (UTC) before calculating the time interval that separates them. This removes any effect that different offsets from UTC may have on the comparison.

System_CAPS_noteNote

For languages that support custom operators, you can also perform date and time subtraction by using the subtraction operator. For details, see the Subtraction method.

Because neither the current DateTimeOffset object nor the value parameter represent the date and time in a specific time zone, the Subtract(DateTimeOffset) method does not consider a particular time zone's adjustment rules when it subtracts dates and times.

The following example illustrates subtraction that uses the Subtract(DateTimeOffset) method.

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: