Python3查找两个纪元毫秒时间之间的持续时间
我有两个纪元时间(以毫秒为单位),我需要找到它们之间的持续时间。 例如:
1637264400000 - 2021 年 11 月 18 日 11:40:00 AM
1637280000000 - 2021 年 11 月 18 日 4:00:00 PM
在这种情况下,时差为 4 小时 20 分钟。我尝试减去两次,如下所示:
1637280000000 - 1637264400000 = 15600000
但后来我不知道如何计算持续时间 15600000 。如果我使用纪元时间转换器,则 15600000 只是转换为 June 30, 1970 6:20:00 AM 。
那么,如何计算天/小时/分钟的持续时间?
I have two epoch times in milliseconds, I need to find the duration between them.
For instance:
1637264400000 - November 18, 2021 11:40:00 AM
1637280000000 - November 18, 2021 4:00:00 PM
In this case the time difference is 4 hours and 20 minutes. I tried to subtract the two times as in :
1637280000000 - 1637264400000 = 15600000
But then I don't know how to compute 15600000 in duration. If I used an epoch time convertor then 15600000 just converts to June 30, 1970 6:20:00 AM .
So, how do I compute the duration in days/hours/minutes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于所有实际目的,您可能希望使用
timedelta< /code>
实例。仅使用毫秒增量:
For all practical purposes you probably want to work with a
timedelta
instance. Using only the milliseconds delta: