I have a string formatted date 2021-12-14T12:05:51.8031499
How can I get the Epoch value of this?
>Solution :
dateutil is your friend, also with 7 digits of fractional seconds:
from dateutil.parser import isoparse
isoparse("2021-12-14T12:05:51.8031499")
Out[2]: datetime.datetime(2021, 12, 14, 12, 5, 51, 803149)
isoparse("2021-12-14T12:05:51.8031499").timestamp()
Out[3]: 1639479951.803149
Note: given ISO format date/time will result in a naive datetime object, which Python will treat as local time, i.e. it will be converted from your machine’s local time setting to UTC before Unix time is calculated for timestamp() !