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)