[Django]-Parse ISO string to date

2👍

Use parser.parse(...) function

In [1]: from dateutil import parser                                                                                                                                                                                

In [2]: dt_str = '2020-09-18T16:11:03.4411565+00:00'                                                                                                                                                               

In [3]: parser.parse(dt_str)                                                                                                                                                                                       
Out[3]: datetime.datetime(2020, 9, 18, 16, 11, 3, 441156, tzinfo=tzutc())
👤JPG

1👍

iso format accepts 6 digit after ‘.’ (usec). You have 7.

Modify your string to ‘2020-09-18T16:11:03.441156+00:00’

👤DuGNu

Leave a comment