刚在MSDN看了篇文章
Determining the Span Between Two Dates
Example
DateTime oldDate = new DateTime(2002,7,15); DateTime newDate = DateTime.Now; // Difference in days, hours, and minutes. TimeSpan ts = newDate - oldDate; // Difference in days. int differenceInDays = ts.Days; Console.WriteLine("Difference in days: {0} ", differenceInDays);
看了些例子,发现什么都要NEW才可以用:(,真麻烦
日期间的间距要这样才可以得出来,麻烦哦。
int differenceInDays = ts.Days;得出两个日期间相差的天数,
int diffhour= ts.Hours;得出的却不是两个日期间相差的总小时数differenceInDays*24,而是不考虑日期,直接对时间进行比较,现在是18点,他得出的结果会是18。好奇怪哦
分钟就也是如此~~
~~做个记号~~明天再接着找我心中疑问的答案