Why do I get different timestamps in python on different machines?

PythonServer Side ProgrammingProgramming

An timestamp is an offset value between a point in time line and the epoch, it's nothing to do with timezone. When it's converted to a human readable string like '%Y-%m-%d %H:%M:%S' that doesn't include any timezone information, python assumes that you want to use local timezone setting.

datetime.timestamp() on a naive datetime object calls mktime() internally i.e., the input is interpreted as the local time. Local time definitions may differ between systems.

C mktime() may return a wrong result if the local timezone had different utc offset in the past and a historical timezone database is not used.

On Unix, when we call timestamp(), the interpreter uses the tz database available on UNIX systems to get the timezone information. While it doesn't have it on windows.

Published on 08-Jan-2018 11:58:59