I have this code:
{% set varfechainiciocontratoprincipal = entity.proyectos.fechainiciocontratoprincipal|date('Y-m-d') %}
the content is varfechainiciocontratoprincipal: 2015-01-10
And other variable:
{% set varduracioncontratoprincipal = entity.proyectos.duracioncontratoprincipal %}
the content is: 540
How make this:
varfechainiciocontratoprincipal + varduracioncontratoprincipal|date("Y-m-d")
I need of result in this format: 2016-10-10 (Is a example)
I probe this format:
{{ varfechainiciocontratoprincipal|date_modify("+540 day")|date("m/d/Y") }}
This work but I need that of number 540 is a variable.
This is actually a time where Twig acts more like PHP where I would use string concatenation to solve the problem.
For ease of reading (and future visitors) I create my own variables:
{% set modify = '540' %}
{% set date = "now"|date("m/d/Y") %}
{{ date|date_modify("+" ~ modify ~ " day")|date("m/d/Y") }}
Result (as of today): 08/31/2016
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.