It will be a string when it comes from the form, but it needs to be in the right format.
Is the date you are setting in the $dates array on the model?
If the column is in date/time format then sending the date as yyyy-mm-dd is the most robust
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys,
I'm using Bootstrap Datepicker* in one of my projects. It looks fine. It pops up and I can select a date and submit the form. Does anyone know where the problem could be?
*https://bootstrap-datepicker.readthedocs.io/en/latest/index.html
Here is my code:
create.blade.php
<div class="container">
<div class="input-group date">
<input type="text" class="form-control" id="datepicker" name="datepicker" value="{{ old('datepicker') }}" placeholder="MM/DD/YYYY">
</div>
</div>
roomscontroller.php
public function store(Request $request)
{
$room = Room::create([
'datepicker' => request()->datepicker
]);
}
createroomstable.php
public function up()
{
Schema::create('rooms', function (Blueprint $table) {
$table->string('datepicker')->nullable();
});
}
Then, since create.blade.php is a section within the app.blade.php file...
app.blade.php
CSS files:
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Bootstrap core CSS -->
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for sticky footer -->
<link href="https://getbootstrap.com/docs/4.0/examples/sticky-footer/sticky-footer.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.standalone.min.css">
JS files:
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<script src="{{ asset('js/app.js') }}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<script>$(document).ready(function() {$('#datepicker').datepicker({startDate: "today()"});});</script>
I have made sure that:
Possible solutions:
Other than that, I'm running out of ideas. Any help is appreciated. Thanks! :)
It will be a string when it comes from the form, but it needs to be in the right format.
Is the date you are setting in the $dates array on the model?
If the column is in date/time format then sending the date as yyyy-mm-dd is the most robust
Please or to participate in this conversation.