Get timezone used by datetime.datetime.fromtimestamp()

datetime.fromtimestamp(ts) converts “seconds since the epoch” to a naive datetime object that represents local time. tzinfo is always None in this case.

Local timezone may have had a different UTC offset in the past. On some systems that provide access to a historical timezone database, fromtimestamp() may take it into account.

To get the UTC offset used by fromtimestamp():

utc_offset = fromtimestamp(ts) - utcfromtimestamp(ts)

See also, Getting computer’s utc offset in Python.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)