To display time with AM and PM we can use the format() method with characters that display time accordingly.
We can get the current time through the datetime module and strftime() function. The datetime module provides the current time and strftime() function represents it.