104

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?

John Saunders
  • 160,644
  • 26
  • 247
  • 397

7 Answers7

157
TimeSpan.FromTicks(28000000000).TotalMinutes;
Patrik Hägne
  • 16,751
  • 5
  • 52
  • 60
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
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
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
11

there are 600 million ticks per minute. ticksperminute

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Blounty
  • 3,342
  • 22
  • 21
4

TimeSpan.FromTicks( 28000000000 ).TotalMinutes;

Mike Scott
  • 12,274
  • 8
  • 40
  • 53
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