which "bootstrap datepicker" are you using? Most allow you to specify the date format.
Date validation in Laravel
Hello,
I want to validate a form request.
'start' => 'required|date|date_format:Y-m-d|after:tomorrow',
'end' => 'required|date|date_format:Y-m-d|after:start'
Those above are the rules.
My problem is when ever I try to fill the dates with Bootstrap-datepicker it gives me an error. The format is not correct. I already know that the format doesn't match, because Bootstrap-datepicker doesn't allow such format like Y-m-d
My question is:
Can I change the format in the rule so it matches the format of Bootstrap-datepicker's format. Like the following
dd-mm-yyyy
I have used to wrok with HTML5 and the attribute date but unfortunately it doesn't work on Firefox.
The language of the datepicker is also important to me.
Thanks guys.
It's probably bc php and that javascript package have different symbols for different date components.
For the datepicker, try what I suggested above yyyy-mm-dd and for the laravel validation rule try Y-m-d. Those should be equivalent.
I'm just suggesting the Y-m-d format bc I assume you're storing this as a date column type in the db.
Please or to participate in this conversation.