简体   繁体   中英

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?

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

If time1 and time2 are in hours: differenceInMinutes = (time2 - time1) * 60

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM