Skip to content

Instantly share code, notes, and snippets.

@mm-uddin
Created May 21, 2022 04:18
Show Gist options
  • Save mm-uddin/3de5a4a74e04395d572f6e65f71d303c to your computer and use it in GitHub Desktop.
Save mm-uddin/3de5a4a74e04395d572f6e65f71d303c to your computer and use it in GitHub Desktop.
Python Code Examples
def show_local_time():
from datetime import datetime
import pytz
print("Please insert your city from cities, Dhaka, Toronto, New York, Sydney : ")
area = input()
area = area.lower()
if area == "dhaka":
time_zone_dhaka = pytz.timezone('Asia/Dhaka')
dt_dhaka = datetime.now(time_zone_dhaka)
print("The local time at your chosen city is : ",dt_dhaka )
elif area == "toronto":
time_zone_toronto = pytz.timezone('America/Toronto')
dt_toronto= datetime.now(time_zone_toronto)
print("The local time at your chosen city is : ",dt_toronto )
elif area == "new york":
time_zone_new_york = pytz.timezone('America/New_York')
dt_new_york = datetime.now(time_zone_new_york)
print("The local time at your chosen city is : ",dt_new_york )
elif area == "sydney":
time_zone_sydney = pytz.timezone('Australia/Sydney')
dt_sydney = datetime.now(time_zone_sydney)
print("The local time at your chosen city is : ",dt_sydney)
else:
print("The city time is not available at the moment")
show_local_time()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment