如何计算不同日期之间的小时 [英] how to calculate hour between different days

查看:119
本文介绍了如何计算不同日期之间的小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想计算两个日期时间选择器之间的时差.但差异总是等于零.
我该怎么办.
neaS

解决方案

可能会有所帮助,

int hours = (dateTimePicker1.Value - dateTimePicker2.Value).TotalHours



TotalHours和Hours之间的实现有所不同,

TotalHours的实现如下所示,

return (this._ticks * 2.7777777777777777E-11);



实施小时数如下所示,

return (int) ((this._ticks / 0x861c46800L) % 0x18L);



将来的参考资料:

Timespan.TotalHours [ Timespan.Hours [ .Net Reflector/ [ int 小时=(dateTimePicker1.Value-dateTimePicker2.Value).小时


hi all,
i want to calculate hours difference between two datetime pickers. but difference always comes out to be zero.
what will i do.
neaS

might be helpful,

int hours = (dateTimePicker1.Value - dateTimePicker2.Value).TotalHours



There is implementation difference between TotalHours and Hours,

TotalHours implementation is something like below,

return (this._ticks * 2.7777777777777777E-11);



Hours implementation is something like below,

return (int) ((this._ticks / 0x861c46800L) % 0x18L);



Future Ref:

Timespan.TotalHours[^]
Timespan.Hours[^]

and .Net Reflector/[^] is the best help.

:)


Doesn''t this works?

int hours = (dateTimePicker1.Value - dateTimePicker2.Value).Hours


这篇关于如何计算不同日期之间的小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆