ItSolutionStuff.com

How to Get Current Time in Python?

By Hardik Savani • October 30, 2023
Python

In this tute, we will discuss python get current time. We will look at example of python get current time in hh mm ss. you will learn python how get current time. I’m going to show you about how to get current time in python.

In this post, i will give you three examples to getting current time in python. we will use datetime module to get current time from date. so let's see following examples with output:

Example 1:

main.py

from datetime import datetime
  
today = datetime.now()
  
currentTime = today.strftime("%H:%M:%S")
print("Current Time:", currentTime);

Output:

Current Time: 09:19:25

Example 2:

main.py

from datetime import datetime
       
currentTime = datetime.now().time()
print("Current Time:", currentTime);

Output:

Current Time: 09:19:25.514195

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Get Current Day in Python?

Read Now →

How to Get Current Year in Python?

Read Now →

How to Get Current Date and Time in Python?

Read Now →

How to Get Current Date in Python?

Read Now →

Laravel Carbon Get Last Day of Month Example

Read Now →

Laravel Carbon addYears() | Laravel Carbon Add Year Example

Read Now →

Laravel Carbon Subtract Months from Date Example

Read Now →

Laravel Carbon addMonths() | Laravel Carbon Add Months Example

Read Now →

Laravel Carbon Subtract Days to Date Example

Read Now →