当前位置:编程学习 > C#/ASP.NET >>

求一个算法,取出耗时秒数

比如有三个时间段:2013/7/25 11:00:20-2013/7/25 11:01:20
                2013/7/25 11:00:30-2013/7/25 11:01:40
                

--------------------编程问答--------------------

        DateTime start = Convert.ToDateTime("2013/7/25 11:00:20");
        DateTime end = Convert.ToDateTime("2013/7/25 11:01:20");

        TimeSpan ts = end - start;
        Console.WriteLine(ts.TotalSeconds);
--------------------编程问答-------------------- http://zhidao.baidu.com/question/14258146.html
这里有你要的答案,把你需要运算的时间相减就可以知道了。 --------------------编程问答-------------------- 两个时间相减,timespan就可以http://www.blogjava.net/AndyZhang/archive/2012/05/02/377157.html --------------------编程问答--------------------                 Dim startTime As DateTime = Convert.ToDateTime("2013/7/25 11:00:20")
                Dim endTime As DateTime = Convert.ToDateTime("2013/7/25 12:00:20")
                Dim dif As TimeSpan = endTime - startTime
                Dim difSecond As Integer = dif.Hours * 3600 + dif.Minutes * 60 + dif.Seconds --------------------编程问答-------------------- --------------------编程问答--------------------         用datediff函数:  
        Dim startTime As Date = Now
        Threading.Thread.Sleep(2000)
        Dim endTime As Date = Now
        MsgBox(DateDiff("s", startTime, endTime)
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,