C#计算时间差,小时差,分钟差,秒差

                DateTime dt1 = DateTime.Now; 
 
                 DateTime dt2 = DateTime.Now.AddHours(-10).AddDays(-10); 
 
                TimeSpan ts = dt1.Subtract(dt2); 
 
                double hours = ts.TotalHours;//24.0

https://msdn.microsoft.com/en-us/library/system.timespan(v=vs.110).aspx

TotalSeconds

TotalMinutes

TotalDays

你可能感兴趣的:(C#计算时间差,小时差,分钟差,秒差)