Create get_times.py

get_times.py Will Fetch Time From Various Timezones :)
This commit is contained in:
codingis4noobs2 2022-10-01 02:15:08 +05:30 committed by GitHub
parent 4f56c75775
commit c65780a30f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,18 @@
# First Install Using The Command Below:
# pip install pytz
from datetime import datetime
import pytz
# list of desired countries
Country_Zones = pytz.all_timezones # pytz.all_timezones will create a list with name of all timezones
country_time_zones = []
for country_time_zone in Country_Zones:
country_time_zones.append(pytz.timezone(country_time_zone))
for i in range(len(country_time_zones)):
country_time = datetime.now(country_time_zones[i])
print(f"The date of {Country_Zones[i]} is {country_time.strftime('%d-%m-%y')} and The time of {Country_Zones[i]} is {country_time.strftime('%H:%M:%S')}") #prints current time of all timezones in Country_Zones