C#中计算两个时间间隔值
// TimeSpan DateTime t1 = Convert.ToDateTime("2020/11/17 12:30:00"); DateTime t2 = Convert.ToDateTime("2020/11/17 12:40:00"); int tsm = t2.Subtract(t1).Duration().Milliseconds;//以毫秒计算 int ts = t2.Subtract(t1).Duration().Seconds;//以秒计算 int tm = t2.Subtract(t1).Duration().Minutes;//以分计算 int th = t2.Subtract(t1).Duration().Hours;//以时计算 int td = t2.Subtract(t1).Duration().Days;//以天计算