I'm trying to convert a date that comes from a datapicker, the date comes in dd/mm/yy
format, but in order to work with it in mysql, I need it to be in yyyy-mm-dd
format.
I'm using the following code:
$ini = $_POST['inicio'];
$newDateini = date( "Y-m-d", strtotime('$ini'));
$newDatefim = date("Y-m-d", strtotime($_POST['fim']));
PS: I could put dateformat
as yy-mm-dd
in the datapicker, but that would make the date confusing for the user.
If I select today's date, for example, and request a echo $ini
, the result will be 28/05/2017
. But when I request a echo $newDateini
instead of returning the date in 2017-05-28
, it returns me as if the date was empty ( 1970-01-01
)