How can I transform a string datetime like this:
"2018-07-13T00:00:00+00:00"
Into this?
"2018-07-13T00:00:00.000000+00:00"
How can I transform a string datetime like this:
"2018-07-13T00:00:00+00:00"
Into this?
"2018-07-13T00:00:00.000000+00:00"
try this out:
from datetime import datetime
datetime_string = "2018-07-13T00:00:00+00:00"
new_datetime_string = datetime.fromisoformat(datetime_string).isoformat(timespec="microseconds")
and for before python V3.7:
date_time = datetime.strptime(datetime_string, '%Y-%m-%dT%H:%M:%S%z').strftime("%Y-%m-%dT%H:%M:%S.%f%z")