Getting epoch format from struct_time in Python

To get the epoch seconds from the struct_time object again, you can use the mktime method of the time module.

Let's get a struct_time object using the gmtime method:

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

Then we transform struct_time using the mktime method:

pythonres = time.mktime(st_time)

print(res) # the number of seconds