You can use Carbon to format the dates correctly.
Carbon::createFromFormat('Y-m-d', $input_name); // whatever your input name is
You'd need to put that in your Controller or wherever you handle the form request.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So I am very new to PHP and Laravel. I believe I have the basics of making a CRUD application but now I am wanting to learn some more. I ran into an issue with taking a date from my Bootstrap theme and converting it to the proper format for SQL. It currently takes YYYY-MM-DD
Here is a sample HTML code
<div class="row">
<!-- DateRange From Input -->
<div class="col-md-6">
<div class="admin-form theme-primary">
<label for="datepicker-from" class="field prepend-icon">
<input type="text" id="datepicker-from" name="datepicker-from" class="gui-input" placeholder="Datepicker From">
<label class="field-icon"><i class="fa fa-calendar-o"></i></label>
</label>
</div>
</div>
<!-- DateRange To Input -->
<div class="col-md-6">
<div class="admin-form theme-primary">
<label for="datepicker-to" class="field prepend-icon">
<input type="text" id="datepicker-to" name="datepicker-to" class="gui-input" placeholder="Datepicker To">
<label class="field-icon"><i class="fa fa-calendar-o"></i></label>
</label>
</div>
</div>
</div>
Here is the sample Javascript
// Datepicker Range From
$("#datepicker-from").datepicker({
defaultDate: "+1w",
numberOfMonths: 3,
prevText: '<i class="fa fa-chevron-left"></i>',
nextText: '<i class="fa fa-chevron-right"></i>',
beforeShow: function(input, inst) {
var themeClass = $(this).parents('.admin-form').attr('class');
var smartpikr = inst.dpDiv.parent();
if (!smartpikr.hasClass(themeClass)) {
inst.dpDiv.wrap('<div class="' + themeClass + '"></div>');
}
},
onClose: function( selectedDate ) {
$("#datepicker-to").datepicker( "option", "minDate", selectedDate );
}
});
// Datepicker Range To
$("#datepicker-to").datepicker({
defaultDate: "+1w",
numberOfMonths: 3,
prevText: '<i class="fa fa-chevron-left"></i>',
nextText: '<i class="fa fa-chevron-right"></i>',
beforeShow: function(input, inst) {
var themeClass = $(this).parents('.admin-form').attr('class');
var smartpikr = inst.dpDiv.parent();
if (!smartpikr.hasClass(themeClass)) {
inst.dpDiv.wrap('<div class="' + themeClass + '"></div>');
}
},
onClose: function( selectedDate ) {
$("#datepicker-from").datepicker( "option", "maxDate", selectedDate );
}
});
Please or to participate in this conversation.