To obtain the current time in the local time zone in pandas, we use the now()
function of Pandas.Timestamp
(an equivalent of Python's datetime
object).
The now()
function takes the following syntax:
Timestamp.now(tz=None)
The now()
function takes a single optional parameter value, tz
, which represents the local timezone.
The now()
function returns a Timestamp object showing the current time.
# A code to illustrate the now() function in Pandas# importing the pandas libraryimport pandas as pd# obtaining the current timeprint(pd.Timestamp.now())
now()
function to obtain the current time and print the value to the console.