About the program
This Python program reads the current system time and prints it in a readable format.
It uses the datetime module.
Python code:
from datetime import datetime
# Get the current time
current_time = datetime.now()
# Print the time as hours, minutes and seconds
print("\n--- Current system time ---")
print("Time:", current_time.strftime("%H:%M:%S"))Sample output:
--- Current system time ---
Time: 20:21:00How it works:
- datetime.now() returns the current system time
- strftime() formats the time for display
- The output shows hours, minutes and seconds