Search code examples
python-3.xdateparser

How to make dateparser parse date relative to a given day


I am using dateparser python's module to parse dates. How can I get dateparser to count not from the current date and time, but from the date I set, like today = datetime(2021, 1, 1)?


Solution

  • Use RELATIVE_BASE in settings.

    For example:

    parse('tomorrow', settings={'RELATIVE_BASE': datetime.datetime(2020, 1, 1)})