C# DateTimeOffset Subtract(DateTimeOffset)

Description

DateTimeOffset Subtract(DateTimeOffset) subtracts a DateTimeOffset value that represents a specific date and time from the current DateTimeOffset object.

Syntax

DateTimeOffset.Subtract(DateTimeOffset) has the following syntax.


public TimeSpan Subtract(
  DateTimeOffset value
)

Parameters

DateTimeOffset.Subtract(DateTimeOffset) has the following parameters.

  • value - An object that represents the value to subtract.

Returns

DateTimeOffset.Subtract(DateTimeOffset) method returns An object that specifies the interval between the two DateTimeOffset objects.

Example

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


//  w  w w . ja  v  a  2 s.  com
using System;
public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset offsetDate = new DateTimeOffset(2014, 12, 3, 11, 30, 0, 
                                   new TimeSpan(-8, 0, 0)); 
    TimeSpan duration = new TimeSpan(7, 18, 0, 0);
    Console.WriteLine(offsetDate.Subtract(duration).ToString());

  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version