Date formatting problem Standard 5.5

Asked

Viewed 39 times

0

I am trying to solve a date formatting issue before sending to database but am not succeeding!

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

input data picker

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 at the bank that way: 1969-12-31

Where is the problem?

1 answer

1


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

$data = '27/02/2018';
echo date('Y-m-d', strtotime(str_replace('/','-',$data)));
  • Thanks for the help, solved the problem!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.