Luis Martins
Luis Martins

Reputation: 1481

Twig's date filter always return current date with valid timestamp

Im having an issue with Twig where any timestamp I pass to the date filter I always get the current date, example:

{{ 1433894400|date }}

This should return the June, 10. But instead it returns the current date. I've tried passing a few different date formats but as expected it makes no change to the output, other than the date format itself that is.

Have anyone had this issue before?

Thank you.

Upvotes: 0

Views: 327

Answers (1)

Kittsil
Kittsil

Reputation: 2477

By the twig docs:

The date filter accepts strings (it must be in a format supported by the strtotime function), DateTime instances, or DateInterval instances. For instance, to display the current date, filter the word "now".

Therefore, use date() to convert your Unix timestamp to a string.

Upvotes: 1

Related Questions