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

Dev0ps's avatar

is there any date validation that accept DOB only greater then 13

i tried ``` Carbon::parse('2000/02/18')->diffInYears() >= 13



but like to work with the validator

because this code does not send error messages
0 likes
2 replies
Cronix's avatar

Find todays date and subtract 13 years. Check that the supplied date is after_or_equal to that value. So if you had a field called "birth_date", it would be something like:

$thirteenYearsAgo = Carbon::now()->subYears(13)->toDateString();

$request->validate([
    'birth_date' => "required|date|after_or_equal:{$thirteenYearsAgo}"
]);

https://laravel.com/docs/5.6/validation#rule-after-or-equal

Please or to participate in this conversation.