title: How to get only the date from a DateTime object?
body: <p>I have a variable of type DateTime() and I want to get only the date of it to compare it with an other date variable. Here is how I tried to do that, but I get extra data that I don't need:</p>
  
  <pre><code>date_default_timezone_set('Africa/Tunis');
  $date= new \DateTime('today');
  $date-&gt;format('d/m/Y');
  </code></pre>
  
  <p><code>var_dump($date)</code> returns : <code>object(DateTime)#617 (3) { ["date"]=&gt; string(19) "2017-04-09 00:00:00" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(12) "Africa/Tunis" }</code>
  So I want to get something like this : 09/04/2017</p>
  
  <p>UPDATE: This is my action code (I have a form in twig that contains a date type input) :</p>
  
  <pre><code> public function addArtAction(Request $request)
      {
  
          $article=new article();
          $em=$this-&gt;getDoctrine()-&gt;getManager();
          $title=$request-&gt;request-&gt;get('titre');
          $content=$request-&gt;files-&gt;get('contenu');
          $dtePub=$request-&gt;request-&gt;get('date');
          date_default_timezone_set('Africa/Tunis');
          $datee= new \DateTime('today');
          $date=$datee-&gt;format('d/m/Y');
  
          if($dtePub==$date)
          {
              $article-&gt;setTitre($title);
              $article-&gt;setCorps($content);
              $article-&gt;setEtat(true);
              $article-&gt;setDtePub($date);
              $em-&gt;persist($article);
              $em-&gt;flush();
              $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('success','Votre article a été archivé!');
          }
          elseif($dtePub&gt;$date)
          {
          $article-&gt;setTitre($title);
          $article-&gt;setCorps($content);
          $article-&gt;setEtat(false);
          $article-&gt;setDteArch($date);
          $article-&gt;setDtePub($dtePub);
          $em-&gt;persist($article);
          $em-&gt;flush();
          $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('success','Votre article a été publié avec succès!');
          }
          elseif($dtePub&lt;$date)
          {
              $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('failure','Vous devez choisir une future date!');
          }
          var_dump($date);
  
      }
  </code></pre>