Python | Panda Timestamp.now

Python Methods and Functions

The Pandas Timestamp.now() function returns the current time in the local time zone. This is equivalent to datetime.now ([tz]).

Syntax: Timestamp.now ()

Parameters: None

Return: Timestamp

Example # 1: Use the Timestamp.now ( ) to return the current time in the local time zone.

# import pandas as pd

import pandas as pd

 
# Create Timestamp object

ts = pd.Timestamp (year = 2011 , month = 11 , day = 21 ,

  hour = 10 , second = 49 , tz = 'US / Central' )

 
# Print the Timestamp object

print (ts)

Output:

Now we will use the Timestamp.now () to find the current time in your local time zone.

# return the current time
ts.now ()

Output:

As we can see in the output, the Timestamp.now () function returned the current time in the local time zone ... It automatically detects the local time zone.

Example # 2: Use the Timestamp.now () function to return the current time in the local time zone.

# import pandas as pd

import pandas as pd

  
# Create Timestamp object

ts = pd.Timestamp (year = 2009 , month = 5 , day = 31 ,

hour  = 4 , second = 49 , tz = 'Europe / Berlin' )

  
# Print the Timestamp object

print (ts)

Output:

Now we will use the Timestamp.now () function to find the current time in your local time zone.

< / table>

Output:

As we can see in the output, the Timestamp.now () function returned the current time in the local time zone. It automatically detects the local time zone.





Get Solution for free from DataCamp guru

# return the current time
ts.now ()