timeobj = datetime.datetime.strptime(my_time, '%Y-%m-%d %H:%M:%S').isoformat() File "/usr/lib/python2.7/_strptime.py", line 335, in _strptime data_string[found.end():]) ValueError: unconverted data remains:
The error was an elusive one. The solution was to make sure that the input time string is exactly as the format expected.
The missing piece was an extra space after the string which was causing format mismatch.
So the solution was to call
strip() on the string before passing it to
- Read the format strip syntax of
datetimeobjects are very handy and general operations such as comparison are inbuilt.