Is it possible to get the timezone in Python given the UTC timestamp and UTC offset?

I have data that are UTC offset and UTC time. Given this, is it possible in Python to get a custom local time zone (mainly to determine if it is a DST, etc., probably using pytz), similar to a function in PHP timezone_name_from_abbr?

For example:

If the time of my era is 1238720309, I can get the UTC time as:

>>> d = datetime.utcfromtimestamp(1238720309)
>>> print d + dt.timedelta(0,-28800) #offset for pacific I think
2009-04-02 17:04:41.712143 

This is correct, except for PDT right now, so it should be:

2009-04-02 18:04:41.712413

I need to get the time zone for use in pytz to find out if it is daylight saving time, I think?

+3
source share
3

, , , : ", ". , , - , .

+5

. , , UTC.

http://en.wikipedia.org/wiki/List_of_time_zones

, -5 UTC , -, , , ..

, , DST, 12 . -, - , , , / (.. / ) .

+1

Source: https://habr.com/ru/post/1705833/


All Articles