Drupal 6. Using Rules and CCK

So, I have a content type that gets automatically generated with Rules. Several CCK fields get populated at creation time, including a datetime field. I want this field to get populated with the current date/time.

For some reason, the Global Token fields don't work, the interface throws an error when I try to use a token instead of a standard formatted date/time stamp.

So, I use advanced PHP code box to set the date/time value.

return array( 0 => array('value' => date("m/d/Y - H:i")), );

This code works, but when I do it this way it seems that whenever I refresh the node page the date/time stamp in the field is updated to whatever the current time is. This is not the behavior I want. I want the date/time to get inserted at creation time, and have it remain unchanged for perpetuity.


  • 1
    Just a thought...why not use $node->created instead of having a custom field with identical data?
    – Clive
    Commented Jul 3, 2012 at 17:13
  • 1
    Yeah fair point. I can't think of any good reason why a node creation rule would be run on a node view though, it doesn't really make sense.
    – Clive
    Commented Jul 3, 2012 at 17:39
  • 1
    I can't say for sure (I've never actually used them) but that sounds very much like what's happening
    – Clive
    Commented Jul 3, 2012 at 18:17
  • 1
    Hmm. Could it be a db issue? Has the column somehow been created as a MySQL timestamp (which updates when the record is accessed)?
    – Clive
    Commented Jul 3, 2012 at 18:27
  • 1
    No worries, glad you got it sorted
    – Clive
    Commented Jul 3, 2012 at 19:17

1 Answer 1


Thanks to Clive's help, I determined the problem was with the field type. There were several similar seeming Date/Time field types available to use, I was using one called "datetime". I switched to another one called "datestamp" and the datestamp field retained its original value after refreshing. I guess the "datetime" field is designed to always return the current datetime value of now(). Thanks for helping me work through this friend!

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.