Posted by wipeout_dude on December 16, 2013 at 5:41pm
Hi,
Seem to be a little stuck..
I have content that has a date field with a start and end date and time..
I want a rule to trigger if the node:field-date:value is between 8am and 8:30am.. I have been trying to create a condition of "Data Comparison" where node:field-date:value is greater than "07:59:59" and another condition where node:field-date:value is lower than "08:31:00".. Even running where node:field-date:value is lower than "08:31:00" on it's own doesn't seem to work..
I assume the correct strtotime syntax is simply hh:mm:ss to apply to any date?
Anyone have any ideas?
Thanks..
Comments
A Suggestion ast to the solution
I wasted a couple of days trying to calculate dates, not suspecting that rules had incorporated the new 'relative formats' for datetime. But finally in desperation I set a value to 'first monday of next month' and hey ho it worked. Nice, wish I'd known.
So use the relative formats to set variables and then use data comparison to do the test.
The syntax of php relative formats is here http://www.php.net/manual/en/datetime.formats.relative.php
Good luck but you should find a mechanism that works.
Tim
This did it for me
I needed to compare a date field with my site date, the problem was that the site is a date and time. In my data comparison i entered 'today' in my data value and everything was working fine!
Many thanks for this tip!!!
Hi Tim, Yes, I have used the
Hi Tim,
Yes, I have used the relative syntax before and it's brilliant but this one has me a little stumped because it doesn't relate to a time from "now" but rather it's relative to the date/time contained in the date field on the node in question..
So if the start date/time in the field of the one node is 2013-12-16 08:00:00 and on another node it's 2013-12-20 08:30:00 the relative "date" will be different but both should evaluate to TRUE because the time is after 07:59:59 and before 08:31:00..
Just hope it doesn't require putting PHP code into the rule because I am rubbish as PHP code.. :)
It may still work
Hi set a variable value using relative dates and you should be ok
The syntax
might work that would set the two variables as 7:59:00 and 8:30:00
Then test the date value against them.
I can tell you that I tried to use a hook_rules_action_info and a hook_rules_condition_info setting the values using date_format and strtotime() it never worked. I could not get a format (even replicating the right date format for a datetime field) to work the date value for a rules variable appears unsettable (or if there is a way noone on IRC or this group knew it).
As I said
Good Luck
Tim