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?
Asked
Active
Viewed 1.6e+01k times
7 Answers
127
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...

Patrick Desjardins
- 136,852
- 88
- 292
- 341
-
lol who down voted me? Both mathematical and coded one really give me 46 min and not this 480 min. – Patrick Desjardins Dec 22 '08 at 14:27
-
1Maybe 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! – Patrik Hägne Dec 22 '08 at 14:49
-
1Actually, to be clear, I have not only removed the down vote. I have up voted your comprehensive answer. Sir. – Patrik Hägne Dec 22 '08 at 15:00
-
6Voted up for including the math version as well as the TimeSpan version. – Rob Kennedy Dec 22 '08 at 15:08
35
You can do this way:
TimeSpan duration = new TimeSpan(tickCount)
double minutes = duration.TotalMinutes;

Uwe Keim
- 39,551
- 56
- 175
- 291

thinkbeforecoding
- 6,668
- 1
- 29
- 31
-
4lol - you answered one minute earlier than Jon Skeet, but his answer has more votes!? – Christian Payne Feb 09 '10 at 04:11
24
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;

Jon Skeet
- 1,421,763
- 867
- 9,128
- 9,194
1
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

zaheer ahmad
- 294
- 4
- 16