I have a CT with a Date (Unix timestamp) field implemented. It represents the start date of an event.

One simply question: Is there a way to compare somehow, this value with the current date() and when it matches (equal) the current date() to trigger an action? It must be equal, other way will trigger an action many times.

Up until now I've tried in hook_node_view to implement the whole logic, no luck.

This hook offers no accuracy on what someone wants to do.

Cron job's aren't suitable, cron isn't running every minute or second.

The other thing I've tried was Rules, but things become complicated, thought is the best way to follow!? Any suggestions?

2 Answers 2


Step 1 - Use VBO and Rules

You could process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

  • Load the VBO list of nodes that you want to be processed (ie those for which the date field matches your criteria).
  • Add a loop to perform a Rules Action, for each node contained in your Views results.

For any node related data you may need in your Rules Actions, make sure that they are contained in the Views result.

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".

Step 2 - Trigger the rule

Use the "Rules Once per Day" module to actually get your rule triggered. Here is how it works (as per the comment in issue 2495775, from the module owner):

  • You specify a trigger hour on the administration settings page for this module.
  • The Rule trigger will then run when cron tasks are first run after the start of that hour. The actual run time will depend on your cron task timings.

So this is another way to understand/read this:

  • The "Event" will only be triggered when a cron job is run.
  • And that event will only be triggered 1 time / day, i.e. "next time cron runs after the trigger hour has passed".

With that, you should be able to adapt the rule from Step 1 to run ... once a day, on any day.

  • 1
    As always, a well written and structured answer! Even though the question is quite old I give it a try as soon as I'll find some spare time.
    – mchar
    Dec 27, 2016 at 10:00

There are ways to compare the current date to a field. Views for instance can have filters that do exactly that. The correct approach will be dependent on what type of action you are trying to perform. If you can expand on this area we can help you figure out what you need to do or what hook you will need to use. For instance if you want to add content to a node on that day you could do the test in hook_preprocess_node().

  • Appreciate your time. Like I said I want to act on the date comparison, Views are performing SQL queries and believe me, the action to be triggered after the comparison it doesn't matter at all, say it's a send mail. The thing is to act on a specific, predefined period of time, to count until the time has come (Event) and then fire a rule (Action). Example: If the start date of an event is on date("Y-m-d H:i:s") and now is date("Y-m-d H:i:s") email all site members.
    – mchar
    Dec 12, 2014 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.