I got a variable with a timestamp in datetime
format:
2022-02-10 11:37:43.253630
And I want theequivalent value in systime
(for unix)
CodePudding user response:
I think you want:
>>> from datetime import datetime as dt
>>> dt.strptime('2022-02-10 11:37:43.253630','%Y-%m-%d %H:%M:%S.%f')
datetime.datetime(2022, 2, 10, 11, 37, 43, 253630)
>>> x = dt.strptime('2022-02-10 11:37:43.253630','%Y-%m-%d %H:%M:%S.%f')
>>> help(x.timestamp)
Help on built-in function timestamp:
timestamp(...) method of datetime.datetime instance
Return POSIX timestamp as float.
>>> x.timestamp()
1644521863.25363