import datetime
ts = datetime.datetime.now().timestamp()
from datetime import datetime
datetime.now(tz=None)
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 = 1528797322
date_time = datetime.fromtimestamp(timestamp)
print("Date time object:", date_time)
d = date_time.strftime("%m/%d/%Y, %H:%M:%S")
print("Output 2:", d)
d = date_time.strftime("%d %b, %Y")
print("Output 3:", d)
d = date_time.strftime("%d %B, %Y")
print("Output 4:", d)
d = date_time.strftime("%I%p")
print("Output 5:", d)
import datetime
from datetime import datetime
timestamp = pd.Timestamp('2020-5-23')
timestamp = <datetime object>.timestamp()