python - How to use abbreviated timezone name(PST, IST) in Pytz -


i need know way of using abbreviated timezone name pst, ist etc on pytz.

now can able convert between timezone using timezone name "america/los_angeles".

instead need find way of using timezone name pst, ist etc.,

sample code have used conversion.

def local2utc(self, dt):      from_zone = tz.gettz('america/los_angeles')     to_zone = tz.gettz('utc')     local = dt.replace(tzinfo=from_zone)     print("converted time")     print(local.astimezone(to_zone).replace(tzinfo = none))     return local.astimezone(to_zone).replace(tzinfo = none) 

someone let me know way of achieving same.

this nature impossible, because abbreviations can mean multiple (different) time zones:

http://www.timeanddate.com/time/zones/

if want work timezones, make dictionary mapping abbreviation long name.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -