Getting the Current Time in Python

Updated: Mar 15

Some people think that getting the time in python is hard and time consuming. However, truth be told, getting the time is simple and a straightforward process. I created a python-based program that will get the current time and print the time in the format “the time is 4:54pm”


What Does this Program do?

This program will get the current time and print the time in the format “the time is 4:54pm”.


Steps to Getting the Time

Some people think that getting the time in python is hard and time consuming. However, truth be told, getting the time is simple and a straight forward process.


On a high level, below are the list of steps to record someone:


i. Getting the date, time, and second


ii. Take the data and second out


iii. Put it in the format you wan’t


iv. Print the time



Step #1: Install Packages

These instructions are meant for python 3.8, if you have an older version you can upgrade or try to follow along, but the code won’t be exactly the same.


Before you start writing python codes, let’s install some packages.


Go to the terminal and type “pip install” with the package name. An example is, “pip install datetime” and press “enter” key.


Similarly, install all the packages listed in the table below, in different lines in the terminal: