我如何在几个小时内的两个日期之间获得差异,从而省略周末的时间?
我需要一个功能来检查两个日期之间已经过去了多少小时,但是例如,如果有一个周末,则跳过这些小时。
日期1:力矩('2022-05-27 20:00:00).tz('utc')
日期2:moment('2022-05-30 20:00:00:00 ).tz('utc')
预期输出:24小时
I need a function to check how many hours have passed between two dates, but if for example there is a weekend in between, then skip those hours.
Date 1: moment('2022-05-27 20:00:00).tz('UTC')
Date 2: moment('2022-05-30 20:00:00).tz('UTC')
Expected output: 24 hours
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我做
i< = n
,我会得到25,而当我做i< n
,但我不使用力矩
请注意,这应该在您所处的环境中跨日光储蓄变化
I get 25 if I do
i <= n
and 24 when I doi < n
But I do not use moment
Note that this should work across daylight savings changes in the locale you are in