1 DateTime oldDate = new DateTime(2002,7,15); 2 DateTime newDate = DateTime.Now; 3 // Difference in days, hours, and minutes. 4 TimeSpan ts = newDate - oldDate; 5 // Difference in days. 6 int differenceInDays = ts.Days;
时间: 2024-11-02 02:03:12
1 DateTime oldDate = new DateTime(2002,7,15); 2 DateTime newDate = DateTime.Now; 3 // Difference in days, hours, and minutes. 4 TimeSpan ts = newDate - oldDate; 5 // Difference in days. 6 int differenceInDays = ts.Days;