I am trying to specify a date field value using custom php code.

return array(0 => array('value' => date("d/m/y - H:t:s"),);

Field always updates to 01/01/09. I notice that the date field default is set to blank, but the field in the action admin screen is 01/01/09. My php is not overriding this value.

Maybe my php is wrong. if that's the case, sorry. I was told it was correct.

Comments

klausi’s picture

Component: Rules Core » Rules Engine

Why do you need the array structure?
I would suggest:
echo date('d/m/y - H:t:s');

klausi’s picture

Ah, ok ... I just saw the "Advanced: Specify the fields value with PHP code" fieldset that requires that array style. Sorry for spam.

tpainton’s picture

I solved this. This is not a rules bug. Date has to be delivered to a date field in ISO format. so date() function should be called as date(c). I did not see this requirement in my perusal of the date api documentation.

tpainton’s picture

Status: Active » Closed (fixed)
medieval111’s picture

Not all PHP versions support the ISO-format using 'c'.
I fixed it by using 'Y-m-d\TH:i:s' instead.

rmanola’s picture

The php snippet that uses that is here:
http://drupal.org/node/520796