I have changed my DB from sqlite to MySQL and now dates stopped to be properly represented. I have a code similar to this:
$receipt = Receipt::create($request->all());
Should I remove the date from request->all() somehow and then modify it by Carbon and then send to the MySQL database - it seems to me a bit complicated. So far I have thought of something like this
$carbonDate = Carbon::createFromFormat('d. m. Y', $date);
$carbonDate->setToStringFormat('Y-m-d');
$request['date']=carbonDate;
Are you setting the protected $dates array in the model? This sets any time stamp besides created at and updated at as carbon instances. Which case your above code for dates isn't required.
Why with oop are you using request as array? Pass an object around uses less memory resources FYI.
@jekinney I have tried that but it didn't work. I have also tried to write setter and it didn't worked also. Still got the date in DB either 0000-00-00 or -0001-11-30 00:00:00. I got datetime picker on my page which gives me dates in dd. mm. YYYY format(d. m. Y) and I am unable to push it to MySQL DB no matter what I try :-/