Get Time in 24 Hour Format with Python in Terminal on Mac - DevPops-Inc/python GitHub Wiki

• Press the “command” key and spacebar to launch Spotlight Search, type “terminal” and select the “Terminal” application.

• Type python3 and press the “return” key to get into the Python interactive shell.

• Type from datetime import datetime and press the “return” key to import the datetime module.

• Type datetime.now().strftime(“%H:%M”) and press the “return” key to get the time in 24-hour format.