Answer the question
In order to leave comments, you need to log in
How to convert number of seconds to date and time in python?
There is a time given in the format (seconds since 00:00:00 01/01/2010 UTC). how to turn it into a convenient view?
Answer the question
In order to leave comments, you need to log in
import datetime
MY_UTC_EPOCH_START = 1262304000 # 00:00:00 01.01.2010 UTC
def my_utcfromtimestamp(ts):
return datetime.datetime.utcfromtimestamp(ts + MY_UTC_EPOCH_START)
datetime.datetime.utcfromtimestamp
one, only applying the correction for the beginning of your "UTC epoch" (midnight January 1, 2010 GMT):>>> my_utcfromtimestamp(1)
datetime.datetime(2010, 1, 1, 0, 0, 1)
>>> my_utcfromtimestamp(123)
datetime.datetime(2010, 1, 1, 0, 2, 3)
>>> my_utcfromtimestamp(3600)
datetime.datetime(2010, 1, 1, 1, 0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question