[edit] Using the DateTime.AddMilliseconds Method
To use the DateTime.AddMilliseconds method you will not specify a timespan. You must specify the amount of Milliseconds you want to add. It accepts a double value so it can calculate partial Milliseconds. Remember, a timespan must NOT be used with DateTime.AddMilliseconds.
- Note: There are 1000 milliseconds in one second
[edit] Syntax
DateTime.AddMilliseconds(<double>)
[edit] Example 1:
using System;
class Program
{
static void Main()
{
DateTime today = DateTime.Now;
Console.WriteLine("today: " + today.ToString());
today = today.AddMilliseconds(6000);
Console.WriteLine("New Date: " + today.ToString());
Console.Read();
}
}
Output:
today: 4/5/2007 8:09:19 PM
New Date: 4/5/2007 8:09:25 PM
As you can see the AddMilliseconds method simply added six seconds to the current date.
<-- DateTime Tutorial
|