Obținerea formatului epoch din struct_time în Python

Pentru a obține din nou secundele epoch dintr-un obiect struct_time, se poate aplica metoda mktime din modulul time.

Să obținem un obiect struct_time cu ajutorul metodei gmtime:

pythonnow = time.time()
st_time = time.gmtime(now)

Apoi transformăm struct_time cu metoda mktime:

pythonres = time.mktime(st_time)

print(res) # va afișa numărul de secunde