Program to convert timestamp string to date-time object using Python

by | Jun 5, 2021 | Python Programs

Home » Python » Python Programs » Program to convert timestamp string to date-time object using Python

Introduction

A timestamp value is number of seconds between the current date and date Jan 1,1970 at UTC. The task is to convert the timestamp value to the date object.

Program

from datetime import datetime
output = datetime.fromtimestamp(1546853289)
print("Date and time is:: ", output)

Output

Program to convert timestamp string to date-time object

Explanation

In the above program, we have used python in-built function fromtimestamp() of datetime module. The fromtimestamp() function takes two argument timestamp value and tz (optional argument).

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author