A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond (see TicksPerMillisecond) and 10 million ticks in a second.
Therefore, in order to calculate the number of days from the number of ticks (rounded to nearest whole numbers), I first calculate the number of seconds by multiplying by ten million, and then multiplying that by the number of seconds in a day (60 seconds in minute, 60 minutes in hour, 24 hours in day).
The smallest unit of time is the tick, which is equal to 100 nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.
The value of this constant is 864 billion; that is, 864,000,000,000.
TimeSpan.FromTicks(28000000000).TotalMinutes;
A single tick represents one hundred nanoseconds or one ten-millionth of a second. FROM MSDN.
So 28 000 000 000 * 1/10 000 000 = 2 800 sec. 2 800 sec /60 = 46.6666min
Or you can do it programmaticly with TimeSpan:
static void Main()
{
TimeSpan ts = TimeSpan.FromTicks(28000000000);
double minutesFromTs = ts.TotalMinutes;
Console.WriteLine(minutesFromTs);
Console.Read();
}
Both give me 46 min and not 480 min...
You can do this way :
TimeSpan duration = new TimeSpan(tickCount)
double minutes = duration.TotalMinutes;
The clearest way in my view is to use TimeSpan.FromTicks and then convert that to minutes:
TimeSpan ts = TimeSpan.FromTicks(ticks);
double minutes = ts.TotalMinutes;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With