日期:2014-05-18  浏览次数:20868 次

两个日期如何相减?
例如:
2012-04-26 12:36:39
2012-04-26 12:36:50

这样的又如何:
2012-04-23 12:36:39
2012-04-30 12:36:50

请问程序应该怎么写呢?

------解决方案--------------------
DateTime t1 = DateTime.Parse("2005-01-01");
DateTime t2 = DateTime.Parse("2006-01-01");
System.TimeSpan ts = t2 - t1;
剩下的就是操作ts了啊 比如求天数的差->
int days = ts.Days;