1from datetime import datetime
2
3timestamp = 1586507536367
4dt_object = datetime.fromtimestamp(timestamp)
5
1import time
2ts = time.time()
3// OR
4import datetime;
5ct = datetime.datetime.now()
6ts = ct.timestamp()
1import datetime
2from datetime import datetime
3timestamp = pd.Timestamp('2020-5-23')
1from datetime import datetime
2
3timestamp = 1545730073
4dt_object = datetime.fromtimestamp(timestamp)
5
6print("dt_object =", dt_object)
7print("type(dt_object) =", type(dt_object))
8
1>>> import time
2>>> import datetime
3>>> s = "01/12/2011"
4>>> time.mktime(datetime.datetime.strptime(s, "%d/%m/%Y").timetuple())
51322697600.0
6