
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Pandas - Get the current date and time from Timestamp object
Get the current date and time from Timestamp object, use the timestamp.today() method.
At first, import the required libraries −
import pandas as pd import datetime
Create the timestamp in Pandas
timestamp = pd.Timestamp(datetime.datetime(2021, 10, 10))
Display the Timestamp
print("Timestamp: ", timestamp)
Getting the current date and time
res = timestamp.today()
Example
Following is the code
import pandas as pd import datetime # set the timestamp in Pandas timestamp = pd.Timestamp(datetime.datetime(2021, 10, 10)) # display the Timestamp print("Timestamp: ", timestamp) # display the day from given timestamp print("Day Name:", timestamp.day_name()) # getting the current date and time res = timestamp.today() # display the current date and time print("\nToday's Date and time...\n", res) # display the current day print("Today's Day:", res.day_name())
Output
This will produce the following code
Timestamp: 2021-10-10 00:00:00 Day Name: Sunday Today's Date and time... 2021-10-03 13:22:28.891506 Today's Day: Sunday
- Related Articles
- Python - Get the weekday from Timestamp object in Pandas
- Set current date and time to timestamp in MySQL
- How to get current date and time in Python?
- Get current time and date on Android
- How to get current date and time from internet in android?
- How to get current date and time from internet in iOS?
- Getting the current date and time with timestamp in local and other timezones in Golang
- Python Pandas - Convert PeriodIndex object to Timestamp
- How to get the current date and time in Java?
- How to get current date and time in JavaScript?
- How to get current date and time using JavaScript?
- How to get current time and date in C++?
- How to get the current date and time from the internet in Android using Kotlin?
- Java Program to Get Current Date/Time
- Get current date/time in seconds - JavaScript?

Advertisements