I have a string date which already contains an appropriate time zone offset -08:00 and I can convert it into a datetime variable but with UTC time zone format:
from datetime import datetime
from pytz import timezone
import pytz
str_date = '2020-01-01T00:00:00-08:00'#
specific_date_format = "%Y-%m-%d %H:%M:%S %Z"
my_date = datetime.fromisoformat(str_date)
print(my_date.strftime(specific_date_format))
_____________________________________________
Output
>> 2020-01-01 00:00:00 UTC-08:00
Format I need is
2020-01-01 00:00:00 PST
Not sure how to convert UTC-08:00 into PST.
Tried with pytz and saw suggestions to replace time zone with predefined 'America/Los_Angeles', but I need the code to detect that the hour offset UTC-08:00 corresponds to 'America/Los_Angeles' time zone and convert it as such.