title: Symfony 3 DateTime from array conversion
body: <p>In Symfony 3, I have the following object</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\HttpFoundation\JsonResponse;
  use Symfony\Component\Filesystem\Filesystem;
  use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
  use Symfony\Component\Serializer\Serializer;
  use Symfony\Component\Serializer\Encoder\JsonEncoder;
  use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  
  /**
   * Shortcut
   *
   * @ORM\Table(name="shortcut", indexes={@ORM\Index(name="idx_user_id", columns={"user_id"}), @ORM\Index(name="idx_short", columns={"short"})})
   * @ORM\HasLifecycleCallbacks()
   * @ORM\Entity
   */
  class Shortcut
      {
          /**
           * @var \DateTime
           *
           * @ORM\Column(name="creation", type="datetime", nullable=true)
           */
          private $creation;
  
           /**
           * Set creation
           *
           * @param \DateTime $creation
           *
           * @return Shortcut
           */
          public function setCreation($creation)
          {
              $this-&gt;creation = $creation;
  
              return $this;
          }
  
          /**
           * Get creation
           *
           * @return \DateTime
           */
          public function getCreation()
          {
              return $this-&gt;creation;
          }
      }
  </code></pre>
  
  <p>When I call getCreation() I have the date, so in twig I do</p>
  
  <pre><code>{{ shortcut.creation | localizeddate('medium', 'none', null) }}
  </code></pre>
  
  <p>but I receive</p>
  
  <pre><code>An exception has been thrown during the rendering of a template ("Notice: Array to string conversion")
  </code></pre>
  
  <p>Because the format is an array and not an instance of DateTime, I have tested with <code>$shortcut-&gt;getCreation() instanceof \DateTime</code></p>
  
  <p>So I have tried to do</p>
  
  <pre><code>public function getCreation()
  {
      return new \DateTime($this-&gt;creation);
  }
  </code></pre>
  
  <p>but it awaits for a string...
  Is it a problem with my database?</p>