Posted By: Anonymous
I am getting a response from the rest is an Epoch time format like
start_time = 1234566 end_time = 1234578
I want to convert that epoch seconds in MySQL format time so that I could store the differences in my MySQL database.
>>> import time >>> time.gmtime(123456) time.struct_time(tm_year=1970, tm_mon=1, tm_mday=2, tm_hour=10, tm_min=17, tm_sec=36, tm_wday=4, tm_yday=2, tm_isdst=0)
The above result is not what I am expecting. I want it be like
Please suggest how can I achieve this?
Why I am getting
TypeError: a float is required for
>>> getbbb_class.end_time = 1347516459425 >>> mend = time.gmtime(getbbb_class.end_time).tm_hour Traceback (most recent call last): ... TypeError: a float is required
To convert your time value (float or int) to a formatted string, use:
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))