Python Language Date and Time Fuzzy datetime parsing (extracting datetime out of a text)

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


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)

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

Got any Python Language Question?