
- 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 - Return a new Timestamp representing UTC day and time
To return a new Timestamp representing UTC day and time, use the timestamp.utcnow() method. At first, import the required libraries −
import pandas as pd
Creating a timestamp
timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC')
New timestamp with UTC day and time
timestamp.utcnow()
Example
Following is the code
import pandas as pd # creating a timestamp timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC') # display the Timestamp print("Timestamp...\n", timestamp) # new timestamp with UTC day and time print("\nUTC day and time...\n", timestamp.utcnow())
Output
This will produce the following code
Timestamp... 2021-10-16 15:12:34.261811624+00:00 UTC day and time... 2021-10-03 07:56:08.901294+00:00
- Related Articles
- Python Pandas - Construct a naive UTC datetime from a POSIX timestamp
- Python Pandas - Get the UTC Offset Time
- Python Pandas - Convert Timestamp to another time zone
- Python Pandas - Return index locations of values at particular time of day in DateTimeIndex
- Python Pandas - Return index locations of values between particular time of day in DateTimeIndex
- Python - Return an array representing the data in the Pandas Index
- Python Pandas - Get the current date and time from Timestamp object
- Python Pandas - Return index locations of values between particular time of day including start time in DateTimeIndex
- Python Pandas - Convert naive Timestamp to local time zone
- Python Pandas - Return the Timestamp representation of the Period object
- Python Pandas - Return the Period object as a timestamp with monthly frequency
- Python Pandas - Return the Period object as a timestamp with minutely frequency
- Python Pandas - Return the Period object as a timestamp with daily frequency
- Python Pandas - Return the Period object as a timestamp with yearly frequency
- How do I convert a datetime to a UTC timestamp in Python?

Advertisements