Python String to TimeZone Aware ISO8601 datetime format

39 Views Asked by At
from datetime import datetime
import pytz

some_date = "2019-01-01"
tzone = "America/Los_Angeles"
print(tzone)
iso_datetime = datetime.strptime(some_date , "%Y-%m-%d").replace(tzinfo=pytz.timezone(tzone).isoformat()

Present output:

America/Los_Angeles
2019-01-01T00:00:00-07:53

Expected output (?): I checked on the internet, it says, Los Angeles is UTC-7:00. This is fine. But my python answers gives a weird answer -07:53. What is wrong here?

2019-01-01T00:00:00-07:00
0

There are 0 best solutions below