计算两个日期之间的差异 [英] Calculate difference between two dates
本文介绍了计算两个日期之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Helloo Experts !!
我想计算两个日期(天)之间的差异,并显示差异日期,例如12 \ 02 \ 09,简而言之,
当前日期:12 \ 02 \ 09
发布日期; 11 \ 02 \ 09
帮助我! [sigh]
Helloo Experts!!
I want to calculate difference between two dates(Day) and display that differnce date like 12\02\09,
In short,
current date:12\02\09
Dispaly date;11\02\09
help me!! [sigh]
推荐答案
您可以在如何使用DateTime上找到很多东西.
请检查 ^ ]
You can find lots of stuff on how to work with DateTime.
Check http://www.dotnetspider.com/forum/164678-date-difference-using-asp-net.aspx[^]
请参见时间跨度类 [ ^ ]
See Timespan class[^]
您可以尝试一下,
DateTime d1 = DateTime.Today;
DateTime d2 = DateTime.Today.AddDays( 1);
TimeSpan ans = d2.Subtract(d1);
如果我没有收到您的问题,请解释.
you can try this,
DateTime d1 = DateTime.Today;
DateTime d2 = DateTime.Today.AddDays(1);
TimeSpan ans = d2.Subtract(d1);
If I didn''t get your problem plz explain it.
这篇关于计算两个日期之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文