I have a bunch of values from a .sql export that are in the datetime format (same format that date fields take in the DB). I'm creating nodes using these date values. How can I insert these values into the date field?

I tried:

$node->field_data_field_date['und'][0]['field_date_value'] = $datetime_value;

but it didn't seem to work. Any ideas? Thanks!

1 Answer 1


If your field's name is field_date you should access it by using

$node->field_date['und'][0]['value'] = $datetime_value;

And if it has an "end" date you have to set its value2 property.

Try to install devel, create a node for the content type you want to use and go to the devel tab node/123/devel to explore its object.

  • D'oh! Guess I got thrown off by the two values and didn't realize that it operates the same as every other field. Thanks for the answer!
    – areynolds
    Commented Oct 25, 2011 at 14:29

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.