Converting Epoch time into the datetime

To convert your time value (float or int) to a formatted string, use:

import time

time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))

For example:

import time

my_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))

print(my_time)

Leave a Comment