C#计算时间差
//计算耗时任务所需的秒数
public int GetTimeSpan(DateTime dtStart, DateTime dtEnd)
{
TimeSpan tsStart = new TimeSpan(dtStart.Ticks);
TimeSpan tsEnd = new TimeSpan(dtEnd.Ticks);
TimeSpan ts = tsEnd.Subtract(tsStart).Duration();//秒
//dateDiff = ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
return ts.Seconds;
}