I have a ticks value of 28000000000 which should be 480 minutes but how can I be sure? How do I convert a ticks value to minutes?
How do I convert ticks to minutes?
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...
lol who down voted me? Both mathematical and coded one really give me 46 min and not this 480 min. –
Sunless
Maybe someone down voted you for rounding 46.6666 to 46? ;-) No, actually, I had down voted you by mistake, I have removed the down vote now. Sorry! –
Ricoriki
Actually, to be clear, I have not only removed the down vote. I have up voted your comprehensive answer. Sir. –
Ricoriki
Voted up for including the math version as well as the TimeSpan version. –
Martainn
You can do this way:
TimeSpan duration = new TimeSpan(tickCount)
double minutes = duration.TotalMinutes;
lol - you answered one minute earlier than Jon Skeet, but his answer has more votes!? –
Mcavoy
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;
there are 600 million ticks per minute. ticksperminute
ticks / TimeSpan.TicksPerMinute –
Christenachristendom
DateTime mydate = new Date(2012,3,2,5,2,0);
int minute = mydate/600000000;
will return minutes of from given date (mydate) to current time.hope this help.cheers
© 2022 - 2024 — McMap. All rights reserved.