在日期验证之前的laravel不起作用

I have two fields, which are: first_date and last_date

These are their validation rules:

'first_date' => 'required|date_format:"Y-m-d"',
        'last_date' => 'required|date_format:"Y-m-d"|before:first_date',

The problem is that what ever the input date is, I get this message:

 The last date must be a date before first date.

I tried these values:

first_date: 2010-5-29
last_date: 2009-5-29

I got that error message though the last date is already before the first date

I tried these values:

 first_date: 2010-5-29
 last_date: 2014-5-29

and I got the same error message.

Help please

You need to update Laravel to v4.2.7. There was a bug with the Before validator that has been fixed and released only yesterday. I could reproduce your problem with v4.2.6 but things work fine in v4.2.7.

In order to update Laravel to the latest 4.2 version, make sure you have

"laravel/framework": "4.2.*"

in your composer.json file and then run composer update.

Try: (month with leading 0):

first_date: 2010-05-29
last_date: 2009-05-29

m Numeric representation of a month, with leading zeros

Source: http://php.net/manual/en/function.date.php