Python convert rfc3339 time to timezone time

joel
1 min readApr 23, 2020

--

import iso8601
import pytz
_date_obj=iso8601.parse_date("2018-09-07T04:57:58.050-07:00")
_date_utc=_date_obj.astimezone(pytz.timezone('America/Toronto'))
_date_utc_zformat=_date_utc.strftime('%Y-%m-%dT%H:%M:%SZ')
print(_date_utc_zformat)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response