Add a specified number of milliseconds to the current DateTimeOffset in CSharp

Description

The following code shows how to add a specified number of milliseconds to the current DateTimeOffset.

Example


using System;/*from  ww  w .j  a v  a2 s .  co  m*/

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset startTime = new DateTimeOffset(2014, 8, 6, 0, 0, 0, 
                         DateTimeOffset.Now.Offset);
    DateTimeOffset startOfShift = startTime.AddMilliseconds(8);
    
    Console.WriteLine("Shifts for the week of {0:D}", startOfShift);
  }
}

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