Convert String to Datetime Object - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Convert String to Datetime Object (/thread-2929.html) |
Convert String to Datetime Object - tkj80 - Apr-20-2017 Hi, I have the following myList[0][0]
type(myList[0][0])
str_date = myList[0][0] from datetime import datetime date_date = datetime.strftime(str_date, "%m/%d/%Y %H:%M:%S")I tried to convert the string object to a datetime object but I got the following error message. Shouldn't with datetime.strftime method, I would be able to convert the string object to datetime object?Wonder if someone could please advise. Thank you! RE: Convert String to Datetime Object - Larz60+ - Apr-20-2017 not tested: datetime.datetime.strptime(date_date, "%Y-%m-%d %H:%M:%S.%f") RE: Convert String to Datetime Object - volcano63 - Apr-20-2017 (Apr-20-2017, 03:44 AM)tkj80 Wrote: Shouldn't with datetime.strftime method, I would be able to convert the string object to datetime object? No, strftime stands for str ing-f rom-time strptime - I would hazard a guess - is str ing-p parse-to-time
|