标签:style blog io ar color os sp on 2014
一个以0.1纳秒为单位的时间戳,就是一个long型的数,其实DateTime本质上就是一个long型的,通过0.1纳秒的单位,换算成各种时间,如果分,秒,年月日等等这些组合起来就是一个DateTime类型了
举例:计算两个时间相隔天数
<pre name="code" class="csharp">public static int GetTimeDifference(DateTime begintime, DateTime endtime)
{
if (begintime > endtime) return 0;
TimeSpan ts1 = new TimeSpan(begintime.Ticks);
TimeSpan ts2 = new TimeSpan(endtime.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
return ts.Days;
}DateTime.Now.Ticks.ToString()说明
标签:style blog io ar color os sp on 2014
原文地址:http://blog.csdn.net/lucky51222/article/details/41655237