日期时间区域 [英] datetime subtarct
本文介绍了日期时间区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个日期时间对象,我想获取它们之间的天数.
我使用了datetime.subtract()
并在时间跨度中将其返回''
时间跨度仅返回天数,而不考虑月份之间的差异.
I have two datetime objects and I want to get the number of days between them.
I used datetime.subtract()
and return it in time span''
Time span returns only the number of days without consideration to the differance between months.
推荐答案
这对我来说很好:
This works fine for me:
static double DiffDays(DateTime dt1, DateTime dt2)
{
return (dt1 - dt2).TotalDays;
}
:)
这篇关于日期时间区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文