How to compare current year with an integer field in Rules? I would like to compare the current year with an integer field (let's say a "year of subscription" field) using Rules (if the field value is lower than the current year, the user has no access to a specific action on the website).

I have tried many different things, data comparison, text comparison, PHP custom etc. but I did not manage to create this "apparently" simple condition.

I guess I am missing something (a date/time comparison somewhere? the right PHP code to extract the year of the current date? echo date('YY')? strtotime? mktime?).

Could anyone help me?
Thanks in advance.
Add the rule as follows:


Event

Your event
Conditions:

a. Entity has field 

-> Data Selector = node 

-> Field Value = your date field (mine is field_bp_year)

b. Execute custom PHP code 

-> Value = 

return intval([node:field-bp-year]) &lt; intval(date("Y")); 

where you add the replacement pattern for your date field (mine was field-bp-year)
Actions:

Your action


NOTE: I treated my year as four digits. If you only want 2 digits then use date("y").