You could use something like this:
<?php
$fecha1 = "24/01/2017"; // Obviamente se cambia por $_POST['fecha1'];
$fechaNueva = date('Y/m/d', strtotime(str_replace('/', '-', $fecha1)));
echo $fechaNueva . "\n";
?>
What we do is change slash to scripts , so that it is easier to read towards the strtotime function.
>
This error occurs because of the following (According to the PHP documentation) strtotime () :
Note:
The dates in the formats m / d / y or d-m-y are not ambiguous when observing the separator between the different components: if the separator is a slash (/), the North American format m / d / y is assumed; whereas if the separator is a hyphen (-) or a period (.), the European format d-m-y is assumed. If, however, the year is provided in a two-digit format and the separator is a hyphen (-, the date string is analyzed as y-m-d.
Result:
2017/01/24