1

I am trying to modify the value 7 in the following twig code:

{{ "now"|date_modify("+7 days")|date("Y/m/d") }}

The above works fine, but if I try this I get an error:

{{ "now"|date_modify("+" . user.days . " days")|date("Y/m/d") }}

Is it possible to edit the number of days dynamically in twig?

1 Answer 1

1

Try to use ~ to concatenate like this :

{{ "now"|date_modify("+" ~ user.days ~ " days")|date("Y/m/d") }}
Sign up to request clarification or add additional context in comments.

1 Comment

@Shaun, you're welcome and thank's for your return. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.