I've search a lot of times and only get converting date from Y-m-d to d-m-Y like this.

```
$date = new DateTime('2000-01-01');
echo $date->format('d-m-Y H:i:s');

```

But I have a string in d-m-Y and want to converte to Y-m-d.

It's just the reverse but I don't know how to do.

===
===

My own answer

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.

```
function data_user_para_mysql($y){
    $data_inverter = explode("/",$y);
    $x = $data_inverter[2].'-'. $data_inverter[1].'-'. $data_inverter[0];
    return $x;
}

```