Listing 09-14: Shows the current date in different time zones

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 09\09.14 - Shows the current date in different time zones.py
# Description: Shows the current date in different time zones
##############################################################################

from zoneinfo import ZoneInfo
from datetime import datetime
brussels = ZoneInfo("Europe/Brussels")
new_york = ZoneInfo("America/New_York")
tokyo = ZoneInfo("Japan")
manaus = ZoneInfo("America/Manaus")
brasilia = ZoneInfo("Brazil/East")
rio_branco = ZoneInfo("America/Rio_Branco")
now = datetime.now()
print("Now in:")
print("Brussels    ", agora.astimezone(brussels))
print("New York    ", now.astimezone(new_york))
print("Tokyo       ", agora.astimezone(tokyo))
print("\nNow in Brazil:")
print("Rio Branco  ", agora.astimezone(rio_branco))
print("Manaus      ", agora.astimezone(manaus))
print("Brasilia    ", now.astimezone(brasilia))
Click here to download the file