Reputation: 111
I'm getting date input from user. It's coming to me as string object and I can't do any operation on it.
I couldn't change my string to datetime object with datetime library.
24th of May 2016 04:00
How can I convert this string to a datetime
type?
Upvotes: 1
Views: 93
Reputation: 363616
Try python-dateutil
, it will chew that string up no problems:
>>> from dateutil.parser import parse
>>> parse('24th of May 2016 04:00')
datetime.datetime(2016, 5, 24, 4, 0)
Upvotes: 2