Parse english textual date expression into datetime
Question: How do I convert these strings:

    
    
    one hour ago
    three days ago
    two weeks ago
    yesterday
    next month
    

into Python datetime object?


Answer: Just found [parsedatetime](https://pypi.python.org/pypi/parsedatetime/1.1.2)
for parsing human readable date/time text from the
[link](http://stackoverflow.com/questions/11340963/natural-language-time-
parser) provided by Jon Clements. Here is a solution in case you interested:

    
    
    from time import mktime
    from datetime import datetime
    import parsedatetime as pdt
    
    time_str = '1 hour ago'
    cal = pdt.Calendar()
    dt = datetime.fromtimestamp(mktime(cal.parse(time_str)[0]))
    time_formatted = dt.strftime('%b %d, %Y %H:%M')
    print(time_formatted) # will print something like: Dec 15, 2013 02:10
    

Also see this question: [python 'x days ago' to
datetime](http://stackoverflow.com/q/12566152/1396314)

