0

I have the following code:

            $node = new stdClass();
            $node->type = 'enterprise_event';
            node_object_prepare($node);
            $node->title = $event->title;
            $node->venue = $event->venue;

My enterprise_event content type also has a date field which is a (start_date - end_date) field, but using the devel module it shows that the field is called date. How can I set the date->start_date, date->end_date values?

Is there something like $node->date->start_date?

1 Answer 1

1

The db columns for a date field's start and end are value and value2 respectively. The usual method to set them would be:

$node->field_date[$node->language][0]['value'] = $from_date;
$node->field_date[$node->language][0]['value2'] = $to_date;
1
  • how it should be used when only one date needs to be updated? When there is only single date and I try to update I find that instead of changing the first value it is adding value2
    – AgA
    Jan 27, 2014 at 6:44

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.