How do I convert ticks to minutes?

后端 未结 7 1551
情书的邮戳
情书的邮戳 2020-12-24 04:25

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条回答
  • 2020-12-24 04:45

    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;
    
    0 讨论(0)
  • 2020-12-24 04:46

    TimeSpan.FromTicks( 28000000000 ).TotalMinutes;

    0 讨论(0)
  • 2020-12-24 04:50
    TimeSpan.FromTicks(28000000000).TotalMinutes;
    
    0 讨论(0)
  • 2020-12-24 04:53

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

    0 讨论(0)
  • 2020-12-24 05:03

    You can do this way :

    TimeSpan duration = new TimeSpan(tickCount)
    double minutes = duration.TotalMinutes;
    
    0 讨论(0)
  • 2020-12-24 05:06

    there are 600 million ticks per minute. ticksperminute

    0 讨论(0)
提交回复
热议问题