How to Get Current Time in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Get Current Day in Python?
- How to Get Current Year in Python?
- How to Get Current Date and Time in Python?
- How to Get Current Date in Python?
- Laravel Carbon Get Last Day of Month Example
- Laravel Carbon addYears() | Laravel Carbon Add Year Example
- Laravel Carbon Subtract Months from Date Example
- Laravel Carbon addMonths() | Laravel Carbon Add Months Example
- Laravel Carbon Subtract Days to Date Example