C# DateTimeOffset AddMilliseconds

Description

DateTimeOffset AddMilliseconds adds a specified number of milliseconds to the current DateTimeOffset object.

Syntax

DateTimeOffset.AddMilliseconds has the following syntax.


public DateTimeOffset AddMilliseconds(
  double milliseconds
)

Parameters

DateTimeOffset.AddMilliseconds has the following parameters.

  • milliseconds - A number of whole and fractional milliseconds. The number can be negative or positive.

Returns

DateTimeOffset.AddMilliseconds method returns An object whose value is the sum of the date and time represented by the current DateTimeOffset object and the number of whole milliseconds represented by milliseconds.

Example


using System;/*from  ww  w.ja va 2 s.c o  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 »
    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