Laravel date check not requiring a four-digit year

I am a little puzzled by the results that I get from checking the Laravel date. The rule in question is as follows:

'date_of_birth'=>array('required', 'date_format:n/j/Y')

What I find is that if someone enters 10/12/13, he passes the check and is stored as 10/12/0013. Obviously, this is not good. Is there a way to get confirmation to require a four-digit year? I assumed that Y would do in format.

+4
source share
1 answer

Posting a comment as an answer

: . . PHP . .

:. , PHP date_parse_from_format(). , :

array('required', 'date_format:n/j/Y', 'regex:/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/')

, , , :

[0-9]{2}= , 0 9.

[0-9]{4}= 4 , 0 9.

\/= . .

: . , , , "99/99/9999", .

after:01-01-1900. , ,

'date_of_birth'=>array('required', 'date_format:"n/j/Y"', 'after:01-01-1900')

(, , ...).

, : , , . PHP DateTime:: createFromFormat().

DateTime::createFromFormat('n/j/Y', '99/99/9999');

"10007-06-07", "01 -01-1900", - , - , - , , . , :)

, , . -

+2

All Articles