add_days

Shifts a date by a whole number of days, forward on a positive amount and back on a negative one, so `{{ now | add_days:14 | date:'Y-m-d' }}` is the date a fortnight from today and add_days:-7 is the date a week ago.

The amount is signed rather than split across an add and a subtract pair, because the interesting amount is usually a field rather than a literal. A notice period read off a row is a number whose sign the template author does not know when they write the pipe, and with a pair they would have to.

The clock time and the zone come through untouched, so a shifted timestamp still names the same moment of the day.

InputArgumentsReturnstime.Timeinttime.Time
Source
BasicSource

Shifts a date forward and writes the result out, which is how a reminder date is worked out at the point it is needed rather than stored on the row.

Given

{"today": moment}

Template

{{ today | add_days:14 | date:'Y-m-d' }}

Result

2024-03-28
BackSource

Shifts a date back, since the amount is signed.

Given

{"today": moment}

Template

{{ today | add_days:-7 | date:'Y-m-d' }}

Result

2024-03-07