;

How to Convert UNIX Timestamp String to Datetime Object in Python


Tutorialsrack 05/03/2021 Python

In this article, you’ll learn how to convert timestamp string to DateTime object in python. We used the fromtimestamp() from datetime module. This method is used to convert the timestamp to readable DateTime format. This function returns the local date corresponding to the POSIX timestamp.

Example: Using datetime.datetime.fromtimestamp() Method

Example: Using datetime.datetime.fromtimestamp() Method
# Import Module
import datetime

Datetime= datetime.datetime.fromtimestamp(
        int("1614948456")
        ).strftime('%Y-%m-%d %H:%M:%S')

# Print Output
print("Date Converted From Timestamp: ",Datetime)
Output

Date Converted From Timestamp:  2021-03-05 18:17:36

I hope this article will help you to understand how to convert timestamp string to DateTime object in python.

Share your valuable feedback, please post your comment at the bottom of this article. Thank you!


Related Posts



Comments

Recent Posts
Tags