Skip to content
Advertisement

Weird timezone issue with pytz

JavaScript

A seven hour and 37 minute offset? This is a little strange, does anyone experience the same issue?

In fact I’m getting different behavior between

JavaScript

Advertisement

Answer

Time zones and offsets change over the years. The default zone name and offset delivered when pytz creates a timezone object are the earliest ones available for that zone, and sometimes they can seem kind of strange. When you use localize to attach the zone to a date, the proper zone name and offset are substituted. Simply using the datetime constructor to attach the zone to the date doesn’t allow it to adjust properly.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement