I am trying to port some code from python2 to python3. I am having trouble when converting some code using date/time manipulations.
Python2.7
Python 2.7.13 (default, Apr 19 2017, 02:44:33)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> import os
>>> os.environ['TZ'] = 'UTC'
>>> datetime.datetime.fromtimestamp(1461085831)
datetime.datetime(2016, 4, 19, 17, 10, 31)
Python3.6
Python 3.6.1 (default, Apr 19 2017, 21:58:41)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> import os
>>> os.environ['TZ'] = 'UTC'
>>> datetime.datetime.fromtimestamp(1461085831)
datetime.datetime(2016, 4, 19, 22, 40, 31)
The result for python2 = (2016, 4, 19, 17, 10, 31) whereas for python3 = (2016, 4, 19, 22, 40, 31).
Why is this difference, and how should I overcome this?
