I'm trying to trigger an action if the action occur before a date (date_a for the purpose of the explanation) stored in a CCK date field. I didn't find many explanations in the documentation.
The condition "CCK", "field has value" doesn't allow to enter token in the "from" and "to" date fields, so I cannot compare date_a with the date of today. Anyway I'm not sure of the use of this condition. Maybe I should use some php code but I don't have many clues about what to enter in the php field. The example talk about "PHP code that returns the value to set", but conditions are not settings values, but testing values :-)
I tried too with the condition "Rules", "numeric comparison". In "number 1" field putting token "[node:site-date" and in "number 2" field trying to find an appropriate token for ex [node:field_date_a-value] or [node:field_date_a-timestamp], but none seems to work. But maybe numeric comparison can't compare dates fields, even if it doesn't seems to complain comparing dates.
Does someone as some suggestion about how to do ?
Comments
Comment #1
amitaibuMaybe try to enable PHP module and then in Rules in the "numeric comparison" :
1st value: [node:field_date_a-timestamp]
2nd value:
<?php return time(); ?>Comment #2
Lionel Triay commentedExactly the information I was looking for ! Thanks very much !
Comment #3
endiku commentedSame question and same great answer. Thank you as well.
Comment #4
garretg commentedHere's another solution that doesn't require enabling the PHP Module. (Note that this is new and not heavily tested.)
Install the Custom Token module, and define a new token.
-- Give it the token ID token_custom_timestamp
-- Give it the description Current Site Timestamp
-- Set type = Global
-- For PHP replacement, enter "return time();" without the quotes
Now, in a Triggered Rule where you want to compare a CCK date field with the site's current timestamp, set up the conditional like this:
Number1: [node:token_custom_timestamp]
Operation: Less than
Number2: [node:field_publishdate-timestamp]
One of the tricks is to put "node:" before your custom token name. It took me a while to figure that out...