laravel validating birthdate by 13 years old

Solutions on MaxInterview for laravel validating birthdate by 13 years old by the best coders in the world

showing results for - "laravel validating birthdate by 13 years old"
Arianna
16 May 2016
1$dt = new Carbon\Carbon();
2$before = $dt->subYears(13)->format('Y-m-d');
3
4$rules = [
5    ...
6    'dob' => 'required|date|before:' . $before
7];
8
9---------------
10  
11Different Solution (Enhanced)
12
13use Carbon\Carbon;
14
15        $dt = new Carbon();
16        $before18Years = $dt->subYears(18)->format('Y-m-d');
17
18
19            'birthdate' => [
20                'date_format:' . config('panel.date_format'),
21                'required',
22                'before:'.$before18Years,
23            ],
24
25file panel.php
26
27<?php
28
29return [
30    'date_format'         => 'Y-m-d',
31    'time_format'         => 'H:i:s',
32    'primary_language'    => 'en',
33];
34
35