How do I convert ticks to minutes?

牧云@^-^@ 提交于 2019-12-18 10:44:10

问题


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?


回答1:


TimeSpan.FromTicks(28000000000).TotalMinutes;



回答2:


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




回答3:


You can do this way :

TimeSpan duration = new TimeSpan(tickCount)
double minutes = duration.TotalMinutes;



回答4:


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;



回答5:


there are 600 million ticks per minute. ticksperminute




回答6:


TimeSpan.FromTicks( 28000000000 ).TotalMinutes;




回答7:


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



来源:https://stackoverflow.com/questions/386341/how-do-i-convert-ticks-to-minutes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!