$data = $_POST["data"];
// Recebe a variável com a data, e cria um objeto DateTime a partir do formato especificado.
$objetoData = DateTime::createFromFormat('d/m/Y', $data);
// Reformata a data do jeito desejado
$data = $objetoData->format('Y-d-m');
To this function where the same makes the exchange date to the format I desire. Example the date enters as 12/13/2018 and when it goes through the exit function 2018-12-13.
The problem is that the function is only working for old dates using the above example only works from day 12 back to day 13 and the current one shows another date that would be 2019-12-01.