Yii Date validation in rules

Here’s how to specify a date validation rules in the Model.

The idea here is that “Date To” should always be greater than “Date From”. Here’s how to do that

public function rules()
   return array(
	array( 'date_to','compare','compareAttribute' => 'date_from','operator'=>'>', 'allowEmpty'=>'false', 'message' => '{attribute} should be greater than "{compareValue}".'),

Piece of cake eh?

Have a happy coding! :)