[英]How to get difference between two timestamps in minutes
Let us consider, that we have two epoch times stored in a variable.让我们考虑一下,我们有两个纪元时间存储在一个变量中。 How do we get the difference between these two times in minutes using python?
我们如何使用 python 在几分钟内得到这两个时间之间的差异?
time1 = 1658952895
time2 = 1658953050
differenceInMinutes = time2 - time1
How to convert the times into minutes depends on the unit of time they are currently in (years, days, hours, etc.).如何将时间转换为分钟取决于它们当前所处的时间单位(年、天、小时等)。 Here are two examples:
这里有两个例子:
If time1 and time2 are in seconds: differenceInMinutes = (time2 - time1) / 60
如果 time1 和 time2 以秒为单位:
differenceInMinutes = (time2 - time1) / 60
If time1 and time2 are in hours: differenceInMinutes = (time2 - time1) * 60
如果 time1 和 time2 以小时为单位:
differenceInMinutes = (time2 - time1) * 60
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.