Hi, I'm sure I'm not the only person who has encountered this, but I've been trying to get validate dates input on a form with little success.
It seems it is OK if you use a US date format, but I need to use a UK date format: "dd/mm/YYYY" instead of "mm/dd/YYYY".
Take the following validation rules:
'commencement_date' => 'required|date|date_format:"d/m/Y"|before:"now"',
'encashment_date' => 'required|date|date_format:"d/m/Y"|before:"now +1 day"'
The 'date' parameter overrides everything, probably because it is being passed to the PHP checkdate function. So, a valid UK date like "13/05/2001" (13 May) will fail. However, if I change the lines to:
'commencement_date' => 'required|date_format:"d/m/Y"|before:"now"',
'encashment_date' => 'required|date_format:"d/m/Y"|before:"now +1 day"'
This will accept any valid UK date, but the "before" parameter does not seem to work, even if I enter a date ten years in the future.
I can't see any way to achieve this without having to construct some custom validation rules.
Any ideas.
Thanks Neil.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community