Date Validation

I’m trying to set a rule for a field named ‘birthdate’ on a profile model. Tried adding:

[[‘birthdate’], ‘date’, ‘format’=>‘yyyy-mm-dd’]

But this just returns The format of Birthdate is invalid, even though the format is set the same way on the jquery date widget and in mysql. When I update without the rule, everything works fine, so I know the date is being set through the form correctly, just want to get the rule working. Any idea on what’s wrong? Any help greatly appreciated, thanks.

Change the model validation rule to:




[['birthdate'], 'date', 'format'=>'Y-m-d']



Thanks Kartik, that worked perfectly.