Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a string to datetime in python [duplicate]

Possible Duplicate:
Parse date and format it using python?

i have a date string like 2011-07-15 13:00:00+00:00 . Any way to convert this string to a datetime object in python ?

Thank You

like image 201
Robert Avatar asked Nov 17 '25 20:11

Robert


1 Answers

You can handle the time zone appropriately, and have the format recognized automatically, if you use dateutil.parser, as described here:

from dateutil import parser
dt = parser.parse("2011-07-15 13:00:00+00:00")
like image 144
Mu Mind Avatar answered Nov 19 '25 09:11

Mu Mind