Hi,
I am trying to have a date field automatically set for X time in the future using a rules set, but regardless what modifications I make, it always defaults to the current date/time. Here is the code that I am using:
return array(
0 => array('value' => strtotime("+1 day"),
);
As it stands now, when the rules is executed, it populates the field with the current date, not 1 day in the future as I tried to specify in the code. The field I am modifying is a Date field (text field) with the format 30 Aug 2008 00:20. Can anyone help?
(I apologize if this is a simple question, or if my code is simply wrong-I am rather new to PHP. Thanks!)
Comments
Comment #1
Druid CreditAttribution: Druid commentedI can see a code error. You're missing a ) and I'd think you'd get some kind of PHP error message from it:
Anyway, get that fixed and see if the behavior changes.
Comment #2
gpy CreditAttribution: gpy commentedThanks for the tip.
I made the change, however, and it continues to do the same thing. Is strtotime the best way to set the date or are there other methods? I read in a few other issues that the Date module defaults to "now" if the format is not correct, but I have tried other custom formats, as well as converting my change from +1 day to +1440 minutes, but the behavior is always the same.
Any other suggestions? I really appreciate the help.
Comment #3
Druid CreditAttribution: Druid commentedDo you have your TZ (timezone) or PHP 5 timezone properly set?
strtotime()
is supposed to return a Unix timestamp integer, but depends on knowing your proper timezone. Watch out especially if your server is quite a few timezones away, or is using GMT. I would print out the returned timestamp and see if it is correct (compare it totime()
value). If it is 24*3600 larger (correct), check that the correct timezone is used, and how you're using this 'value' later.Comment #4
gpy CreditAttribution: gpy commentedI'm not sure exactly what to do here. My site timezone is set to US Central, and the date field is set to use the user's timezone.
Comment #5
tmsimont CreditAttribution: tmsimont commentedI'm seeing the exact issue, setting the value of the field either with php code (I've tried like 5 different ways..) and with a string input on a textfield within the rules module. I don't know if it's rules or me or what, but it's driving me nuts. Was there ever resolution to this? I am seeing this in 6.x-2.7, setting the field value with a rule.
edit: rather than revive an old issue, i've opened a new one that is more specific to the issue in rules:
http://drupal.org/node/1118854
Comment #6
notluap CreditAttribution: notluap commentedI am also having this issue. Setting a cck date field via php with rules, the cck date field always spouts out the current time.
Comment #7
DamienMcKennaWe're sorry but the D6 release of Date module is no longer being supported. You are encouraged to update to Drupal 7 or 8, or direct questions to Drupal Answers.