File tree Expand file tree Collapse file tree 4 files changed +626
-1
lines changed Expand file tree Collapse file tree 4 files changed +626
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ When you Add a project Add it to the README for ease of finding it
7272
7373* [ Image Grayscalling] ( https://github.com/larymak/Python-project-Scripts/tree/main/Image%20Grayscalling )
7474
75- * [ Gettin Files and Folders sizes] ( https://github.com/Saeedahmadi7714/Python-project-Scripts/tree/main/Gettin%20File%20and%20Folder%20sizes )
75+ * [ Getting Files and Folders sizes] ( https://github.com/Saeedahmadi7714/Python-project-Scripts/tree/main/Gettin%20File%20and%20Folder%20sizes )
7676
7777_ more coming soon_
7878
Original file line number Diff line number Diff line change 1+ ### This is a simple program to print Custom current clock
2+
3+ How use it :
4+
5+ 1- Choose your timezone in file timezones.txt
6+
7+ 2- python3 getting_current_time.py
8+
9+ - output with Asia/Tehran timezone :
10+ Current time in this timezone: 2021:06:23 19:45:29 +0430
11+
Original file line number Diff line number Diff line change 1+ from datetime import datetime
2+ import pytz
3+ from pytz import UnknownTimeZoneError
4+
5+ # Get time zone name from user
6+ user_entered_time_zone = input ('Enter your time zone: ' )
7+
8+
9+ def get_current_time (time_zone_name ):
10+ # It will get the time zone of the user location
11+ time_zone_name = pytz .timezone (time_zone_name )
12+
13+ # Print the date and time in specified format
14+ current_time = datetime .now (time_zone_name )
15+ print (f"Current time in this timezone: { current_time .strftime ('%Y:%m:%d %H:%M:%S %Z' )} " )
16+
17+
18+ try :
19+ get_current_time (user_entered_time_zone )
20+ except UnknownTimeZoneError :
21+ print ('UnknownTimeZoneError... \n Please try again with correct time zone.' )
You can’t perform that action at this time.
0 commit comments