mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
Create get_times.py
get_times.py Will Fetch Time From Various Timezones :)
This commit is contained in:
parent
4f56c75775
commit
c65780a30f
18
Get_Time_TimezoneWise/get_times.py
Normal file
18
Get_Time_TimezoneWise/get_times.py
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user