Subtract a DateTimeOffset that represents a specific date and time from the current DateTimeOffset in CSharp

Description

The following code shows how to subtract a DateTimeOffset that represents a specific date and time from the current DateTimeOffset.

Example


/* w  w w  . j  ava 2s  . c o  m*/
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 »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var