A few days ago the need to add variables in twig, to be precise having a date for example: 2016-01-04 I need to add 540 days for this I use the date_modify plugin present in twig.
To perform this operation you must perform the following:
{% In September modify = '540'%}
{% In September date = "now" | date ( "m / d / Y")%}
{{Date | date_modify ( "+" ~ ~ modify "day") | date ( "m / d / Y")}}
With this the result would be: 08/31/2017
Do you know another way?
{{ 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With