Python Get Current Second Example

Published On: 01/09/2022 | Category: Python


Hi Guys,

In this example, I will show you python get current second example. let’s discuss about how to get current second in python. I explained simply about how to get current second in python 3. I’m going to show you about python get today second. Here, Creating a basic example of python get current second.

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

So let's see bellow example:

Example 1: main.py
from datetime import datetime
  
today = datetime.now()
  
print("Current Date and Time :", today)
print("Current Second :", today.second)
Output:
Current Date and Time : 2022-09-01 06:03:54.113858
Current Second : 54
Example 2: main.py
from datetime import datetime
  
today = datetime.now()
    
second1 = today.strftime("%S")
print("Current Second:", second1);
Output:
Current Second: 21

It will help you....