How to add days to a variable date in twig How to add days to a variable date in twig symfony symfony

How to add days to a variable date in twig


{{ yourDate|date_modify("+1 day")|date("m/d/Y") }}

this code add 1 day to your date.

see http://twig.sensiolabs.org/doc/filters/date_modify.html


Just in case someone needs to add more than +1 day in a twig template

{% set sevenDays = date(yourDate)|date_modify("+7 days")|date("d/m/Y")%}

Once the variable set can be used anywhere in the template


This worked for me:

{% set tomorrow = 'now'|date_modify("+1 day") %}<input id="event_date" name="event_date" class="datepicker" type="date" value="{{ tomorrow|date('Y-m-d') }}" />