I've got a jquery datepicker
$(function() {
var date = new Date();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$('.datepicker').datepicker({
showOn: 'focus',changeMonth: true,
minDate: new Date(currentYear, currentMonth, currentDate),
changeYear: true,
});
});
with some validation
$this->validate($request, [
"date" => 'required|date',
]);
and some conversion for the date to pass through to the database
$date = $request->input('date');
$date2 = DateTime::createFromFormat('m/d/Y',$date);
$date3 = $date2->format("Y-d-m");
If I dd($date3) at this point, with a chosen date, I get something like this
"2016-29-09"
All well and good, mysql appears to save in a y-d-m format.
Now when I go to pass it through
Message::where('id', $messageId)->update([
'updated_at' => Carbon\Carbon::now(),
'subject' => 'Status: Price quote delivered.',
'quoted' => 1,
'price' => $request->input('price'),
'estimated_date' => $date3,
]);
everything gets passed to the database except the date. The date just stays at 0000-00-00 in the database.
Help?