Fuzzy datetime parsing extracting datetime out of a text

suggest change

It is possible to extract a date out of a text using the dateutil parser in a “fuzzy” mode, where components of the string not recognized as being part of a date are ignored.

from dateutil.parser import parse

dt = parse("Today is January 1, 2047 at 8:21:00AM", fuzzy=True)
print(dt)

dt is now a datetime object and you would see datetime.datetime(2047, 1, 1, 8, 21) printed.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents