Date formatting problem laravel 5.5

0

I'm trying to resolve a date formatting problem before sending it to the database but I'm not succeeding!

I'm using in a form the datapicker plugin, as shown in the image below:

In my Controller I have this line of code:

$agenda_exame->data = date('Y-m-d', strtotime($request->data_exame));

And you're saving the date on the bank like this: 1969-12-31

Where is the problem?

    
asked by anonymous 03.02.2018 / 18:11

1 answer

1

Your date is probably going with '/', in php you need to replace with '-' example:

$data = '27/02/2018';
echo date('Y-m-d', strtotime(str_replace('/','-',$data)));
    
03.02.2018 / 18:26