You might want to explore pendulum. pendulum
is Python's datetime
made easy!
Just install it with:
$ pip install pendulum
Usage for your case:
import pendulum
dt = pendulum.parse("2021-01-29T13:29:19.668Z")
print(dt.format("MMM DD, YYYY @ h:mm A"))
Output:
Jan 29, 2021 @ 1:29 PM
EDIT: To get the time in EST
(modifying the time), just do this:
import pendulum
dt = pendulum.parse("2021-01-29T13:29:19.668Z")
print(dt.in_tz("America/Toronto").format("MMM DD, YYYY @ h:mm A"))
Output:
Jan 29, 2021 @ 8:29 AM
However, if you don't want to modify the output but just set the timezone, try this:
dt = pendulum.parse("2021-01-29T13:29:19.668Z").set(tz="America/Toronto")
print(dt.timezone)
print(dt)
print(dt.format("MMM DD, YYYY @ h:mm A"))
Output:
Timezone('America/Toronto')
2021-01-29T13:29:19.668000-05:00
Jan 29, 2021 @ 1:29 PM