106

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?

7 Answers 7

157
TimeSpan.FromTicks(28000000000).TotalMinutes;
128

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...

4
  • lol who down voted me? Both mathematical and coded one really give me 46 min and not this 480 min. Dec 22, 2008 at 14:27
  • 1
    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! Dec 22, 2008 at 14:49
  • 1
    Actually, to be clear, I have not only removed the down vote. I have up voted your comprehensive answer. Sir. Dec 22, 2008 at 15:00
  • 6
    Voted up for including the math version as well as the TimeSpan version. Dec 22, 2008 at 15:08
35

You can do this way:

TimeSpan duration = new TimeSpan(tickCount)
double minutes = duration.TotalMinutes;
1
  • 4
    lol - you answered one minute earlier than Jon Skeet, but his answer has more votes!? Feb 9, 2010 at 4:11
26

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;
11

there are 600 million ticks per minute. ticksperminute

1
  • 2
    ticks / TimeSpan.TicksPerMinute Dec 4, 2011 at 20:32
4

TimeSpan.FromTicks( 28000000000 ).TotalMinutes;

0
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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.