Haythem Belhadj
Haythem Belhadj

Reputation: 35

Display timestamp variable in Twig Symfony

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.

Upvotes: 1

Views: 1374

Answers (1)

Francesco Abeni
Francesco Abeni

Reputation: 4265

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.

Upvotes: 2

Related Questions