标签:
t1 = DateTime.Now.AddDays(3); t2 = DateTime.Now.AddDays(68); int i = (t2 - t1).Days; -------------------------------------------------------- C#中计算2个时间之间的差(可以计算到时分秒); 参考代码如下: label1.Text = "2012-1-1 15:36:05"; label2.Text = "2012-2-1 20:16:35"; DateTime d1 =new DateTime(2012,1,1,15,36,05); DateTime d2 =new DateTime(2012,2,1,20,16,35); TimeSpan d3 = d2.Subtract(d1); label3.Text = "相差:" +d3.Days.ToString()+"天" +d3.Hours.ToString()+"小时" +d3.Minutes.ToString()+"分钟" +d3.Seconds.ToString()+"秒";
标签:
原文地址:http://www.cnblogs.com/xh0626/p/4947169.html