1

How to print a variable in twig html file such as for date:
{{ timeComment|date('Y-m-d') }}

I've tried date('Y-m-d H:i:s') but it doesn't work.

2
  • 2
    it should work, what does it print ? Commented Jun 6, 2016 at 0:46
  • Not sure what you're trying to achieve, can you clarify your question? Commented Jun 6, 2016 at 7:02

1 Answer 1

2

If you want to print the current datetime, you can do this:

{{ "now"|date('Y-m-d H:i:s') }}

See http://twig.sensiolabs.org/doc/filters/date.html for details.

Sign up to request clarification or add additional context in comments.

Comments

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.