0

教義を介してデータベースから小枝ページのすべてのレコードを取得すると、このエラーが見つかります

ここに私の小枝コードがあります:

    {% extends "gestionConferenceApplicationBundle::layout.html.twig" %}
{% block title "Hello " ~ name %}
{% block content %}
je suis un debutant
<table border=2 >
    <th>Numéro</th>
    <th>Titre</th>
    <th>Ville</th>
    <th>Lieu</th>
    <th>Date de début</th>
    <th>Date de fin</th>

    {% for item in conferences %}
    <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.titre }}</td>
        <td>{{ item.ville }}</td>
        <td>{{ item.lieu }}</td>*
        <td>{{ item.dateDebut }}</td>
        <td>{{ item.dateFin }}</td>        
    </tr>     
     {% endfor %}
</table>
{% endblock %}

日付のエラー:

ここにあります :

An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class DateTime could not be converted to string in C:\wamp\www\Symfony\app\cache\dev\twig\3c\dd\40a703549de9b8769fa40b82230e.php line 72") in gestionConferenceApplicationBundle:acceuil:acceuil.html.twig at line 19.

この日付やその他のものを変換する方法はありますか

MySqlにはdateTimeフィールドがあり、教義には次のものがあります:

/**
 * @var \DateTime $dateDebut
 *
 * @ORM\Column(name="date_debut", type="datetime", nullable=false)
 */
private $dateDebut;
4

1 に答える 1

0

私はそれを行うべき解決策を見つけます:

<td>{{ item.dateDebut|date('d/m/Y') }}</td>
    <td>{{ item.dateFin|date('d/m/Y') }}</td>
于 2012-12-03T17:01:56.800 に答える