score:21

Accepted answer

Once you figure out what you want to calculate milliseconds from, you can just take one DateTime object from another to get a TimeSpan object. From TimeSpan you can get TotalMilliseconds.

In other words, if start and end are DateTime objects, you can do this:

double milliseconds = (end - start).TotalMilliseconds;

score:1

DateTime[] dates = ;

var minDate = dates.Min();

var msDates = dates.Select(date => (date - minDate).TotalMilliseconds).ToArray();

score:6

The .Ticks in C# DateTime gives you the value of any time in ticks. You can thereafter convert to milliseconds as shown below:

long dateticks = DateTime.Now.Ticks;
long datemilliseconds = dateticks / TimeSpan.TicksPerMillisecond;

score:12

You can use the DateTime.Ticks property and convert the value to milliseconds.

The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001, which represents DateTime.MinValue. It does not include the number of ticks that are attributable to leap seconds.

A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.


Related Query

More Query from same tag