-2

I need to parse string type value which looks like 017-11-18T05:26:01.778+0000

datetime_object = datetime.strptime(date_in_string, "%Y-%m-%d %H-%M-%S-%j-%f")

but it gives mistake like

ValueError: time data '2017-11-18T05:26:01.778+0000' does not match format '%Y-%m-%d '

Where is my mistake?

1 Answers1

-1
from dateutil.parser import parse
parse(date_in_string, fuzzy=True)

you have a timezone parameter also in your date, that's the reason of your error

armak
  • 560
  • 5
  • 13
  • for further information on parsing these type of dates you can look https://stackoverflow.com/questions/10298032/parsing-date-and-timestamps-in-python-with-time-strptime-format – armak Nov 25 '17 at 14:49
  • as useful as dateutil might be, there's no reason to use it to answer the question - providing the correct format string would be much more helpful. – bruno desthuilliers Nov 25 '17 at 15:03