how to convert string to timestamp in python code example
Example 1: convert to timestamp python
import datetime
date = '18/05/2020 - 18:05:12'
date = datetime.datetime.strptime(date, "%d %m %Y - %H:%M:%S"")
date = datetime.datetime.timestamp(date)
Example 2: get timestamp from string python
import datetime
date = '18/05/2020 - 18:05:12'
date = datetime.datetime.strptime(date, "%d %m %Y - %H:%M:%S")
date = datetime.datetime.timestamp(date)
Example 3: python convert timestamp to datetime
from datetime import datetime
timestamp = 1545730073
dt_object = datetime.fromtimestamp(timestamp)
print("dt_object =", dt_object)
print("type(dt_object) =", type(dt_object))