It seems parsedatetime
module that should parse human-readable date/time text works in this case:
#!/usr/bin/env python
from datetime import datetime
import parsedatetime as pdt # $ pip install parsedatetime
cal = pdt.Calendar()
print(datetime.now())
for time_str in ["8 seconds ago", "5 minutes ago", "11 hours ago",
"11:34 AM yesterday"]:
dt, flags = cal.parseDT(time_str)
assert flags
print(dt)
Output
2015-06-26 21:07:19.108521
2015-06-26 21:07:11
2015-06-26 21:02:19
2015-06-26 10:07:19
2015-06-25 11:34:00
0
solved How to convert unformatted time to a python time object