Tampa Tampa - 1 year ago 60
Python Question

python 2.7 how to use a time stamp that is utc on another server

This is my timestamp on my utc server:


Now for debugging purposes...

I convert to a datetime object but this is what I get:

2016-11-21 23:35:00+00:00

How do I fix so its 2016-11-21T15:35?

Answer Source

Use the proper method, utcfromtimestamp.

>>> import datetime
>>> datetime.datetime.fromtimestamp(1479742500)
datetime.datetime(2016, 11, 21, 7, 35)
>>> datetime.datetime.utcfromtimestamp(1479742500)
datetime.datetime(2016, 11, 21, 15, 35)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download