- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Pandas - Get the UTC Offset Time
To get the UTC Offset Time, use the timestamp.utcoffset(). 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()
Get the UTC offset time
timestamp.utcoffset()
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()) # Get the UTC offset time print("\nUTC offset time...\n", timestamp.utcoffset())
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:44.685816+00:00 UTC offset time... 0:00:00
Advertisements