Tampa
Tampa

Reputation: 78402

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

This is my timestamp on my utc server:

2016-11-21T15:35
1479742500

Now for debugging purposes...

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

 datetime.datetime.fromtimestamp(1479742500)
 2016-11-21 23:35:00+00:00

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

Upvotes: 0

Views: 38

Answers (1)

TigerhawkT3
TigerhawkT3

Reputation: 49330

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)

Upvotes: 2

Related Questions