Convert datetime to Timestamp in Python

To convert datetime to Timestamp in Python, use the timestamp() function from the datetime module of Python.

Example

import datetime

date_str = datetime.datetime.strptime('2021-03-11 16:00:13', "%Y-%m-%d %H:%M:%S")
timestamp = datetime.datetime.timestamp(date_str)
print(timestamp)
Output
1615457713.0