datetime object to unix timestamp python code example
Example 1: python datetime to timestamp
import datetime
now = datetime.datetime.today()
timestamp = datetime.datetime.timestamp(now)
Example 2: get datetime from unix timestamp python3
from datetime import datetime
timestamp = 1545730073
dt_object = datetime.fromtimestamp(timestamp)
print("dt_object =", dt_object)
print("type(dt_object) =", type(dt_object))