how to convert time to timestamp python code example
Example 1: convert to timestamp python
import datetime
date = '18/05/2020 - 18:05:12'
# convert string to datetimeformat
date = datetime.datetime.strptime(date, "%d %m %Y - %H:%M:%S"")
# convert datetime to timestamp
date = datetime.datetime.timestamp(date)
Example 2: python 2.7 datetime to timestamp
import time
from datetime import datetime
d = datetime(2017, 6, 11, 0, 0)
unixtime = time.mktime(d.timetuple())