#region 获得两个日期的间隔
/// <summary>
/// 获得两个日期的间隔
/// </summary>
/// <param name="DateTime1">日期一。</param>
/// <param name="DateTime2">日期二。</param>
/// <returns>日期间隔TimeSpan。</returns>
public static TimeSpan DateDiff(DateTime DateTime1, DateTime DateTime2)
{
TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
return ts;
}
#endregion
时间: 2024-11-08 06:33:24