Question

pytz's documentation says:

Note that this instance [pytz.timezone('UTC')] is not the same instance (or implementation) as other timezones with the same meaning (GMT, Greenwich, Universal, etc.).

and indeed:

>>> pytz.timezone('UTC') is pytz.timezone('GMT')
False

So... what's the difference?
When should I use pytz.timezone('UTC') and when should I use pytz.timezone('GMT')?

Was it helpful?

Solution

The UTC implementation is a tzinfo implementation that will at all times return 0 minutes offset.

The timezone you get when you do pytz.timezone('GMT') is the GMT timezone defined in the Olson database. It also will return 0 at all times, but in a more complicated manner.

Use UTC.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top