Originariamente ho fatto questo codice per convertire la data nel tempo leggibile:Python - Convertire secondi di tanto epoca nel tempo leggibile
a = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S.%f")
b = datetime.datetime.now()
c = b - a
days, hours, minutes, seconds = int(c.days), int(c.seconds // 3600), int(c.seconds % 3600/60.0), int(c.seconds % 60.0)
return days, hours, minutes, seconds
EXAMPLE OUTPUT: 1 days, 4 hours, 24 minutes, 37 seconds
e sto cercando di farlo usando il tempo epoca, ma non ho idea su di renderlo calcolare days ore ed ecc
a = last_epoch #last epoch recorded
b = time.time() #current epoch time
c = b - a #returns seconds
hours = c // 3600/24 #the only thing I managed to figure out
Questa risposta dovrebbe aiutare fuori: [Come posso produrre una differenza leggibile quando sott utilizzando due timestamp UNIX usando Python?] (http://stackoverflow.com/questions/6574329/how-can-i-produce-a-human-readable-difference-when-subtracting-two-unix-timestam) – siame
@JohnZwinck nessuna domanda non ha risposto, otterrò l'anno 1970 se convertirò secondi da last_epoch - time.time() –