Python Print Timestamp
import datetime
ts = datetime.datetime.now().timestamp()
Plain Partridge
import datetime
ts = datetime.datetime.now().timestamp()
from datetime import datetime
timestamp = 1586507536367
dt_object = datetime.fromtimestamp(timestamp)
import time
ts = time.time()
// OR
import datetime;
ct = datetime.datetime.now()
ts = ct.timestamp()
from datetime import datetime
# Returns a datetime object containing the local date and time
dateTimeObj = datetime.now()
print(dateTimeObj)
# Output
# 2018-11-18 09:32:36.435350
from datetime import datetime
timestamp = 1545730073
dt_object = datetime.fromtimestamp(timestamp)
print("dt_object =", dt_object)
print("type(dt_object) =", type(dt_object))
>>> import time
>>> import datetime
>>> s = "01/12/2011"
>>> time.mktime(datetime.datetime.strptime(s, "%d/%m/%Y").timetuple())
1322697600.0