How to compare two timezones in python?


 import pytz

These two timezones have different names but represent the same thing, however

  • b==c returns false
  • is different than

Is there any way to see that b is in reality equal to c?

The concrete problem is that I have to convert the timezone of a pandas data frame, but only if this zone is different than let’s say c. The original timezone might be b and in this case I do not want to convert as it would be a lost of time to convert b into c (since they represent the same time zones at the end….)

Thanks for any help.

changed ‘CET’ into ‘Europe/Rome’ to make sure that the timezones are the same in the example, using the feedback from an answer

Best answer

It’s kind of ghetto, but I could compare the offsets of both timezones against a given a timestamp.

from datetime import datetime
today =
b.utcoffset(today) == c.utcoffset(today)