简体   繁体   English

如何在几分钟内获得两个时间戳之间的差异

[英]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.

相关问题 如何以天为单位获得两个时间戳之间的差异? - How to get the difference between two timestamps in days? 具有两个时间戳之间的差异的列 - Column with difference between two timestamps Pandas | 如何获取包含时间戳的两列之间的时间差(以秒为单位) - Pandas | How to get the time difference in seconds between two columns that contain timestamps 如何计算 discord.py 中两个时间戳 _a 和 _b 之间的差异? - how to calculate difference between two timestamps _a and _b in discord.py? 如何计算两个时间戳之间的小时差并排除周末 - How to calculate the difference between in hours two timestamps and exclude weekends 如何在几分钟内在列表中计算python中10个或更多unix时间戳之间的差异并将其取平均值 - How to Calulate the difference between 10 or more unix timestamps in python in a list in minutes and average them 在python中以分钟为单位获取两个日期时间对象之间的差异 - Get the difference between two datetime objects in minutes in python 不同工作日的两个时间戳之间的区别? - Difference between two timestamps with different weekdays? 使用熊猫在两个时间戳之间以分钟为单位的每小时时间序列 - Hourly time series in minutes between two timestamps using Pandas 计算两个时间戳 python 之间的时间间隔(以分钟为单位) - calculate time interval in minutes between two timestamps python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM