Yii Framework Forum: Problems with date compare - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problems with date compare Rate Topic: -----

#1 User is offline   guillemweb 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 12-May 14

Posted 01 September 2015 - 05:33 AM

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.
1

#2 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 900
  • Joined: 19-February 13
  • Location:India

Posted 01 September 2015 - 06:39 AM

Hi There,



Please change the operator >= to > and try that

I hope it's works.


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




Thanks,
Ankit Modi
Skype : amodi06
0

#3 User is offline   guillemweb 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 12-May 14

Posted 01 September 2015 - 07:01 AM

Hi Ankit,

your code is the same of me. Thanks

View PostAnkit Modi, on 01 September 2015 - 06:39 AM, said:

Hi There,



Please remove the operator >= and try that

I hope it's works.


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





0

#4 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 01 September 2015 - 04:35 PM

Hi Guillemweb

Please check this wiki.

It also has a date-compare example.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users