Display MST, EST, CST, IST digital time

 import pytz

from datetime import datetime # Define time zones est_timezone = pytz.timezone('US/Eastern') # Eastern Standard Time (EST) mst_timezone = pytz.timezone('US/Mountain') # Mountain Standard Time (MST) cst_timezone = pytz.timezone('US/Central') # Central Standard Time (CST) ist_timezone = pytz.timezone('Asia/Kolkata') # Indian Standard Time (IST) while True: # Get current time in different time zones est_time = datetime.now(est_timezone) mst_time = datetime.now(mst_timezone) cst_time = datetime.now(cst_timezone) ist_time = datetime.now(ist_timezone) # Format the time time_format = '%Y-%m-%d %H:%M:%S' # You can adjust the format as needed digital_time_est = est_time.strftime(time_format) digital_time_mst = mst_time.strftime(time_format) digital_time_cst = cst_time.strftime(time_format) digital_time_ist = ist_time.strftime(time_format) # Clear the console print("\033[H\033[J") # ANSI escape codes to clear the screen # Display the digital time for different time zones print("Digital Time (24-Hour Format)") print(f"Eastern Standard Time (EST): {digital_time_est}") print(f"Mountain Standard Time (MST): {digital_time_mst}") print(f"Central Standard Time (CST): {digital_time_cst}") print(f"Indian Standard Time (IST): {digital_time_ist}") # Update every second time.sleep(1)

This code uses the pytz library to handle time zones and the datetime library to format and display the digital time for each specified time zone. The program continuously updates the time every second and clears the console to provide an updated display.

Please make sure to install the pytz library if you haven't already by using pip install pytz. Adjust the time format and time zones as needed.

Comments

Popular posts from this blog

Ecommerce website

Yes, Python is an object-oriented programming (OOP) language, but it is also a multi-paradigm language

Your task is to find the missing number.