Support the ongoing development of Laravel.io →
Input Forms

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.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.