代码如下: //计算耗时任务所需的秒数 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() + “