Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BeginnerSoul's avatar

After or equal is ok

Hello I am trying to use the after_or_equal:date validation but no idea how to use. It would be nice to check if the date is 30 years or less would be but NOT more than 30. It means now we have 2022 and from 1992 would be allowed and before 1992 wouldn't be allowed. I did think to use after_or_equal validation but no idea how I could make possible that the laravel will calculate how much year would be the minimum if 30 years is the difference and add to the validation.

How I can make possible? Thanks in advance the answers.

0 likes
2 replies
Nakov's avatar
Nakov
Best Answer
Level 73

Try this:

'date' => 'required|date|after_or_equal:' . now()->subYears(30)->format('Y-m-d H:i:s')
1 like

Please or to participate in this conversation.