System.DateTimeOffset.Subtract Method

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

Syntax

public TimeSpan Subtract (DateTimeOffset value)

Parameters

value
An object that represents the value to subtract.

Returns

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

Remarks

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.

Note:

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

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

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0