I've created a Calendar view and I can add custom content types (with date field) to the calendar via the the Drupal administer overlay.

I'm now attempting to add the content node via php code (and set the date field) like this:

    $node = new StdClass();
    $node->type = 'event_2';
    $node->title = t($tb2_event->name);
    $node->field_event_date_2[LANGUAGE_NONE][0]['value'] = strtotime($tb2_event->start_time);
    $node->field_event_date_2[LANGUAGE_NONE][0]['value2'] = strtotime($tb2_event->start_time);
    $node->uid = $user->uid;
    $node->status = 1;
    $node->active = 1;
    $node->promote = 1;
    $node->comment = 1;
    $node->created = strtotime("now");
    node_submit($node);
    node_save($node);

When I check back in Drupal Admin, I see that the Content has successfully been created, along with title and correct date. However, it does not show up in the Calendar until I hit the save button in Drupal Admin.

Can somebody please advise.

Thanks.

Comments

docteurdem’s picture

Issue summary: View changes

I got the same issue by doing like you said, have any solution ?

$node->field_event_date_2[LANGUAGE_NONE][0]['value'] = strtotime($tb2_event->start_time);
$node->field_event_date_2[LANGUAGE_NONE][0]['value2'] = strtotime($tb2_event->start_time);

rudeboypeter’s picture

Ancient issue obviously, but just hit the same thing myself. Programmatically created nodes do not appear in Calendar views unless loaded and saved manually.