title: Converting php string d-m-y to date y-m-d
body: <p>I've search a lot of times and only get converting date from Y-m-d to d-m-Y like this.</p>
  <pre><code>$date = new DateTime('2000-01-01');
  echo $date-&gt;format('d-m-Y H:i:s');
  </code></pre>
  <p>But I have a string in d-m-Y and want to converte to Y-m-d.</p>
  <p>It's just the reverse but I don't know how to do.</p>
  <h1>===</h1>
  <p>My own answer</p>
  <p>People said that my question is already questioned.
  But people don't understand that my date var is a STRING and return erro when I tried what they say as a solution.
  My date var is a STRING in this format DD/MM/YYYY, I discover the solution searching it in pt-br on google.
  This is the solution.</p>
  <pre><code>function data_user_para_mysql($y){
      $data_inverter = explode(&quot;/&quot;,$y);
      $x = $data_inverter[2].'-'. $data_inverter[1].'-'. $data_inverter[0];
      return $x;
  }
  </code></pre>