Convert datetime to Timestamp in Python

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

Here's an example to demonstrate this:

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)

The output of the above code is as follows:

1615457713.0