solvit.io

Twig Error: Object of class DateTime could not be converted to string

Solution

Apply the Twig date filter when displaying any variable of type DateTime.

Example
{# this produces an error #}
{{ item.updatedAt }}

{# this works as expected #}
{{ item.updatedAt|date }}
Find more solutions about: , , , , ,