Python fromtimestamp returns inconsistent results on different machines

I have two computers, for the first:

>>> datetime.datetime.fromtimestamp(0) datetime.datetime(1970, 1, 1, 7, 30) >>> datetime.datetime.fromtimestamp(1309846824) datetime.datetime(2011, 7, 5, 14, 20, 24) 

for the second:

 >>> datetime.datetime.fromtimestamp(0) datetime.datetime(1970, 1, 1, 8, 0) >>> datetime.datetime.fromtimestamp(1309846824) datetime.datetime(2011, 7, 5, 14, 20, 24) 

How can they differ by "0" by agreeing to "1309846824"?

+8
python datetime timestamp
source share
1 answer

Here is an excerpt from the "asia" file that uses tzdata. On debian / ubuntu you can get this file by running apt-get source tzdata

 ...
 # Zone NAME GMTOFF RULES FORMAT [UNTIL]
 Zone Asia / Kuala_Lumpur 6:46:46 - LMT 1901 Jan 1
                         6:55:25 - SMT 1905 Jun 1 # Singapore MT
                         7:00 - MALT 1933 Jan 1 # Malaya Time
                         7:00 0:20 MALST 1936 Jan 1
                         7:20 - MALT 1941 Sep 1
                         7:30 - MALT 1942 Feb 16
                         9:00 - JST 1945 Sep 12
                         7:30 - MALT 1982 Jan 1
                         8:00 - MYT # Malaysia Time
 ...

This describes how the time zone in Kuala Lumpur has changed since 1901. So in 1970 we see that GMT + 7.5 is now GMT + 8

Windows does not use any form of tzdata, therefore it only knows the current offset

+2
source share

All Articles