Having a timestamp as string like 2016-09-22T13:57:31.2311892-04:00
, how can one get the datetime object?
I've tried using strptime
for this, but I got two issues:
- I need to remove
:
from the timezone part, at the end, for%z
to work properly. - The microseconds part has 7 digits, but
strptime
handles only up to 6 digits.
Is there a way to parse timestamps in this format without modifying* the string itself before passing to strptime
?
* - by modifying, I think of removing the last microsecond digit, and removing the last :
.
Note: This is for inserting a record in MySQL. If that helps.