返回时间差[返回秒]
/// <summary> /// 返回时间差[返回秒] /// </summary> /// <param name="DateTimex">时间1(小)</param> /// <param name="DateTimed">时间2(大)</param> /// <returns>返回秒</returns> public static double TDiff(DateTime DateTimex, DateTime DateTimed) { return ((TimeSpan)(DateTimed - DateTimex)).TotalSeconds; }
程序调用:TDiff(DateTime.Now, DateTime.Now.AddHours(1))
运行结果:3600