title: Symfony2 DateTime could not be converted to string
body: <p>Hello guys i have problem when i try to render date when is some data created and modified.</p>
  
  <p>I have Album bundle and when i create new Album item i insert in database date when is that album created and when is modified. I success insert that data in database but i have problem only when i try to render.</p>
  
  <p><strong>Error what i get is :</strong></p>
  
  <blockquote>
    <p>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
    /home/ikac/public_html/Symfony/app/cache/dev/twig/6f/eb/a068a5eed37d5c1eca1228cc7bb9.php
    line 56") in DevAlbumBundle:Default:index.html.twig at line 19. 500
    Internal Server Error - Twig_Error_Runtime 1 linked Exception:</p>
  
  <pre><code>ContextErrorException »
  </code></pre>
  </blockquote>
  
  <p>Check my Entity and controller for this actions:</p>
  
  <pre><code>&lt;?php
  
  namespace Dev\AlbumBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Albums
   *
   * @ORM\Table(name="albums")
   * @ORM\HasLifecycleCallbacks()
   * @ORM\Entity(repositoryClass="Dev\AlbumBundle\Entity\AlbumsRepository")
   */
  class Albums
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="title", type="string", length=255)
       */
      private $title;
  
      /**
       * @var string
       *
       * @ORM\Column(name="description", type="text")
       */
      private $description;
  
      /**
       * @var string
       *
       * @ORM\Column(name="background", type="string", length=255)
       */
      private $background;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="date_created", type="datetime", nullable=true)
       */
      private $dateCreated;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="date_modified", type="datetime", nullable=true)
       */
      private $dateModified;
  
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set title
       *
       * @param string $title
       * @return Albums
       */
      public function setTitle($title)
      {
          $this-&gt;title = $title;
  
          return $this;
      }
  
      /**
       * Get title
       *
       * @return string 
       */
      public function getTitle()
      {
          return $this-&gt;title;
      }
  
      /**
       * Set description
       *
       * @param string $description
       * @return Albums
       */
      public function setDescription($description)
      {
          $this-&gt;description = $description;
  
          return $this;
      }
  
      /**
       * Get description
       *
       * @return string 
       */
      public function getDescription()
      {
          return $this-&gt;description;
      }
  
      /**
       * Set background
       *
       * @param string $background
       * @return Albums
       */
      public function setBackground($background)
      {
          $this-&gt;background = $background;
  
          return $this;
      }
  
      /**
       * Get background
       *
       * @return string 
       */
      public function getBackground()
      {
          return $this-&gt;background;
      }
  
      /**
       * Set dateCreated
       *
       * @ORM\PrePersist
       * @return Albums
       */
      public function setDateCreated()
      {
          $this-&gt;dateCreated = new \DateTime();  
  
          return $this;
      }
  
      /**
       * Get dateCreated
       *
       * @return \DateTime 
       */
      public function getDateCreated()
      {
          return $this-&gt;dateCreated;
      }
  
      /**
       * Set dateModified
       *
       * @ORM\PreUpdate
       * @return Albums
       */
      public function setDateModified()
      {
          $this-&gt;dateModified = new \DateTime();
  
          return $this;
      }
  
      /**
       * Get dateModified
       *
       * @return \DateTime 
       */
      public function getDateModified()
      {
          return $this-&gt;dateModified;
      }
  }
  </code></pre>
  
  <p>I also try this :</p>
  
  <pre><code>/**
   * Set dateCreated
   *
   * @ORM\PrePersist
   * @return Albums
   */
  public function setDateCreated()
  {
      $this-&gt;dateCreated = new \DateTime(date('Y-m-d H:i:s'));
  
      return $this;
  }
  </code></pre>
  
  <p><strong>Controller Action:</strong></p>
  
  <pre><code>/**
   * Album Add
   * 
   * @Route("/album/add")
   * 
   * @return  @return Dev\AlbumBundle\Controller\DefaultController:add()
   */
  public function addAction() {
      $album = new Albums();
      $album-&gt;setTitle("Nojeva Barka");
      $album-&gt;setDescription("Album Bore Corbe");
      $album-&gt;setBackground("background.png");
  
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $em-&gt;persist($album);
      $em-&gt;flush();
  
      return new Response('Album created '. $album-&gt;getTitle()); 
  }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <pre><code>&lt;table border="1"&gt; 
          &lt;thead&gt;
              &lt;th&gt; #ID &lt;/th&gt;
              &lt;th&gt; Title &lt;/th&gt;
              &lt;th&gt; Description &lt;/th&gt;
              &lt;th&gt; Background &lt;/th&gt;
              &lt;th&gt; Date Created &lt;/th&gt;
              &lt;th&gt; Date Modified &lt;/th&gt;
              &lt;th&gt; Action &lt;/th&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              {% for item in album %}
                  &lt;tr&gt;
                      &lt;td&gt; {{ item.id }} &lt;/td&gt;
                      &lt;td&gt; {{ item.title }} &lt;/td&gt;
                      &lt;td&gt; {{ item.description }} &lt;/td&gt;
                      &lt;td&gt; {{ item.background }} &lt;/td&gt;
                      &lt;td&gt; {{ item.dateCreated|date('Y-m-d H:i:s') }} &lt;/td&gt;
                      &lt;td&gt; {{ item.dateModified|date('Y-m-d H:i:s') }} &lt;/td&gt;
                      &lt;td&gt; &lt;a href="edit"&gt; Edit &lt;/a&gt; &lt;a href="delete"&gt; Delete &lt;/a&gt; &lt;/td&gt;
                  &lt;/tr&gt;
              {% endfor %}
          &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Thanks for help!</p>