Manually enter custom timestamp So I'm making quite a few nodes through a script, an action. To do this I'm using the form_state drupal_execute method.

However because there is a lot of processing per node in one batch I get lots of nodes with different time stamps.

Is there any way to manually edit the timestamps a part from going into the DB? I've tried this:
outside loop:

$time = time();


inside loop:


form_state['values'] = $time;


And give the same timestamp to all the nodes. But apparently druapl_execute gives them a new time stamp.

Thanks.

EDIT: Solved!
I ended up adding this line, it was the fastest solution I could think of.


db_query("UPDATE  {node} SET  created = %d WHERE  nid = %d", $time, $form_state['nid']);
Another solution is assigning the created property of the $node object before calling $node-&gt;save.

e.g.

$body_text = 'This is the body text I want entered with the node.';
$created_time = time();

$node = new stdClass();
$node-&gt;type = 'article';
node_object_prepare($node);

$node-&gt;title    = 'Node Created Programmatically on ' . date('c');
$node-&gt;language = LANGUAGE_NONE;

$node-&gt;body[$node-&gt;language][0]['value']   = $body_text;
$node-&gt;body[$node-&gt;language][0]['summary'] = text_summary($body_text);
$node-&gt;body[$node-&gt;language][0]['format']  = 'filtered_html';

$path = 'content/programmatically_created_node_' . date('YmdHis');
$node-&gt;path = array('alias' =&gt; $path);

$node-&gt;created = $created_time;

node_save($node);


For more information please see the API docs on node_save().

The solution above has the added bonus of not requiring additional databases queries to clean up the timestamps after the node was created.