Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fuzzy timestamp parsing with Python

Is there a Python module to interpret fuzzy timestamps like the date command in unix:

> date -d "2 minutes ago"
Tue Aug 11 16:24:05 EST 2009

The closest I have found so far is dateutil.parser, which fails for the above example.

thanks

like image 583
hoju Avatar asked Aug 11 '09 06:08

hoju


2 Answers

Check out this open source module: parsedatetime

like image 93
Nick Dandoulakis Avatar answered Nov 07 '22 17:11

Nick Dandoulakis


dateparser

Usage:

>>> import dateparser
>>> dateparser.parse('2 minutes ago')
datetime.datetime(2018, 11, 27, 13, 44, 54, 993170)
>>> dateparser.parse('yesterday at 15:12')
datetime.datetime(2018, 11, 26, 15, 12)
like image 37
idanp Avatar answered Nov 07 '22 17:11

idanp