Problems with date compare

Hi there,

I’m use this code in my model/rules to compare two dates, but sometimes this rule doesn’t work correctly. I want that DateOut date will be bigger than DateIn


array('DateOut','compare','compareAttribute'=>'DateIn','operator'=>'>=', 'allowEmpty'=>false , 'message'=>'{attribute} no puede ser anterior a "{compareValue}".'),

For example I’ve problems if put as DateIn 30/09/2015 and DateOut 05/10/2015.

Thanks for your help.

Hi There,

Please change the operator >= to > and try that

I hope it’s works.

[font="Arial"][size="4"]


array( 'event_end_date','compare','compareAttribute'=>'event_start_date','operator'=>'>', 'allowEmpty'=>false , 'message'=>'{attribute} must be greater than "{compareValue}".'),

[/size][/font]

Hi Ankit,

your code is the same of me. Thanks

Hi Guillemweb

Please check this wiki.

It also has a date-compare example.