我正在从 xml 自动创建节点,我需要为它们设置创建日期。我试过了
<?php
...
$node->created = $date //<- unix timestamp, $node is my node object
$node->changed = $other_date;
...
?>
但没有运气,它设置了当前日期。有任何想法吗?谢谢
-编辑-
$newNode = (object) NULL;
$newNode->type = 'blog';
$newNode->title = $title;
$newNode->uid = 1;
$newNode->status = 1;
$newNode->comment = 0;
$newNode->moderate = 0;
$newNode->sticky = 0;
$newNode->body['und'][0] = array(
'value' => $body,
'format' => 'full_html');
$newNode->log = 'Auto Imported Node';
$newNode->language = LANGUAGE_NONE;
// add fields
$newNode->field_description[LANGUAGE_NONE][0]['value'] = $description;
$newNode->field_byline[LANGUAGE_NONE][0]['value'] = $byline;
$newNode->field_small_image[LANGUAGE_NONE][0]['value'] = $smallimg;
$newNode->field_large_image[LANGUAGE_NONE][0]['value'] = $largeimg;
// save node
$newNode->created = $pd; // i've tried with commenting this line out, too
$newNode->date = $pd;
node_save($newNode);