比较2个时间的差值
#region 计算两个时间差值的函数,返回时间差的绝对值 /// <summary> /// 计算两个时间差值的函数,返回时间差的绝对值/分钟 /// </summary> /// <param name="DateTime1"></param> /// <param name="DateTime2"></param> /// <returns>时间差的绝对值/分钟</returns> private int DateDiff(DateTime DateTime1, DateTime DateTime2) { int dateDiff = 0; try { TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); TimeSpan ts2 = new TimeSpan(DateTime2.Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); dateDiff = ts.Days * 24 * 60 + ts.Hours * 60 + ts.Minutes; //dateDiff = ts.Days.ToString() + "天" // + ts.Hours.ToString() + "小时" // + ts.Minutes.ToString() + "分钟" // + ts.Seconds.ToString() + "秒"; } catch { } return dateDiff; } #endregion