Question

I'm parsing datetimestamps using python dateutil, but would like to avoid the extra dependency. So Is there a way to do the equivalent with the standard python library:

dateutil.parser.parse("2012-12-12T12:00")

Thanks a lot!

Was it helpful?

Solution

If your date strings are all in the same format, you could use strptime like this:

In [31]: import datetime as DT

In [32]: DT.datetime.strptime("2012-12-12T12:00", '%Y-%m-%dT%H:%M')
Out[32]: datetime.datetime(2012, 12, 12, 12, 0)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top