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

  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts

Comments

Leave a Reply

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.