1import datetime
2date = '18/05/2020 - 18:05:12'
3
4# convert string to datetimeformat
5date = datetime.datetime.strptime(date, "%d %m %Y - %H:%M:%S"")
6
7# convert datetime to timestamp
8date = datetime.datetime.timestamp(date)
1from datetime import datetime
2
3timestamp = 1586507536367
4dt_object = datetime.fromtimestamp(timestamp)
5
1import datetime
2import pytz
3my_date = datetime.datetime.now(pytz.timezone('US/Pacific'))
1import datetime
2now = datetime.datetime.today()
3timestamp = datetime.datetime.timestamp(now)
1
2from datetime import datetime
3
4# current date and time
5now = datetime.now()
6
7timestamp = datetime.timestamp(now)
8print("timestamp =", timestamp)
9