I am trying to convert time from America/New York to UTC and then converting it back to the New York time. But I get different results while doing with this with pytz
.
I am doing this:
new_date = parser.parse("May 4, 2021")
new_date = new_date.replace(tzinfo=pytz.timezone("America/New_York"))
date = new_date.astimezone(pytz.timezone("UTC"))
Output:
datetime.datetime(2021, 5, 4, 4, 56, tzinfo=<UTC>)
When I try to reconvert it back to the New York time I get this:
date.astimezone(pytz.timezone("America/New_York"))
I get:
datetime.datetime(2021, 5, 4, 0, 56, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
My Question is why there is 56 minute difference and what can be done to prevent this?