time_epoch = time.time()
print(time_epoch)
time_struct = time.gmtime(time_epoch)
print(time_struct)
time_formatted = time.strftime('%Y-%m-%d %H:%M:%S', time_struct)
print(time_formatted)
Convert mysql timestamp to epoch time in python