日期:2014-05-17 浏览次数:20812 次
DateTime dt1 = Convert.ToDateTime("2010/11/25 20:53:43"); DateTime dt2 = Convert.ToDateTime("2010/11/26 19:24:53"); int i = DateTime.Compare(dt1, dt2);
DateTime dt1 = Convert.ToDateTime("2010/11/25 20:53:43"); DateTime dt2 = Convert.ToDateTime("2010/11/25 20:53:43"); DateTime dt3 = Convert.ToDateTime("2010/11/25 20:53:43"); TimeSpan diff1 = dt2.Subtract(dt1); DateTime diff2 = dt3.Subtract(dt1); TimeSpan diff3 = dt2 - dt3; DateTime diff4 = dt1 - dt2;
TimeSpan ts = new TimeSpan(40, 0, 0, 0); DateTime dt1 = DateTime.Now.Subtract(ts); DateTime dt2 = DateTime.Now.Add(ts); string str1 = ts.Days.ToString() + "天前是" + dt1.ToString("yyyy年MM月dd日"); string str2 = ts.Days.ToString() + "天后是" + dt2.ToString("yyyy年MM月dd日");