44. Timestamp to Datetime Object and Datetime Object to Timestamp in Python with Code || Module-III

Published: 13 August 2022
on channel: Bhavatavi
9
0

Timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds. we have imported datetime class from the datetime module. Then, we used datetime.fromtimestamp(timestamp) classmethod which returns the date and time.

Code:

from datetime import datetime
timestamp=1665730073
dt_object=datetime.fromtimestamp(timestamp)
print("dt_object=",dt_object)
print("type(dt_object",type(dt_object))

now=datetime.now()
timestamp=datetime.timestamp(now)
print("Timestamp=",timestamp)


On this page of the site you can watch the video online 44. Timestamp to Datetime Object and Datetime Object to Timestamp in Python with Code || Module-III with a duration of hours minute second in good quality, which was uploaded by the user Bhavatavi 13 August 2022, share the link with friends and acquaintances, this video has already been watched 9 times on youtube and it was liked by 0 viewers. Enjoy your viewing!