title: Object of class DateTime could not be converted to string - Symfony/PHP
body: <p>When i submit my form it shows me this error:</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").</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/5dw1Z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5dw1Z.png" alt="Full message Error"></a></p>
  
  <p>I don't know what i'm doing wrong , this is my code ( PHP )</p>
  
  <pre><code>   -&gt;add('purchasedate', DateType::class, array(
              'widget' =&gt; 'single_text',
              'html5' =&gt; false,
              'label' =&gt; 'Date d’achat (JJ/MM/AAAA)*',
            ))
  </code></pre>
  
  <p>Purchase Date:</p>
  
  <pre><code>/**
   * @var string
   *
   * @ORM\Column(name="purchasedate", type="date")
   * @Assert\Range(
   *      min = "2019-01-14",
   *      max = "2019-04-14"
   * )
   * 
   * 
   * @Serializer\SerializedName("purchasedate")
   * @Serializer\Expose()
   * 
   */
  
  private $purchasedate;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ZRkU9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZRkU9.png" alt="Get and Set Method"></a></p>
  
  <p><strong>Solution</strong></p>
  
  <p>I was trying to display the date in a twig template is where the error showed up. I only update the display code</p>
  
  <pre><code>{{ user.purchasedate|date('d-m-Y') }}
  </code></pre>