DEV Community

Tony Colston
Tony Colston

Posted on

3 1

Python and timezones

I recently needed to see what time it was in another timezone. Again this is a good task for Python (everything is really).

There is a great package named pendulum that is made exactly for this.

See here: https://pendulum.eustace.io/

So if I need to know what time it is in Japan...

import pendulum
now_in_japan = pendulum.now("Japan")
now_in_japan
Enter fullscreen mode Exit fullscreen mode

That is easy to read and showed me exactly what I wanted.

Also if you want to know what timezones your system knows about look in /usr/share/zoneinfo. Not sure about windows :(

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay