Skip to content
Advertisement

How to solve datetime format error “time data %r does not match format %r”?

I’m trying to convert a date from string format to a datetime format. I think that I’m using the right format, but the error is still raised.

Code example:

JavaScript

Error:

JavaScript

Advertisement

Answer

Your code wasn’t reading the microseconds properly. You can read microseconds with %f

Try using this code, this will fix the issue:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement