Skip to content

Instantly share code, notes, and snippets.

@guoxiangke
Created April 16, 2014 23:34
Show Gist options
  • Save guoxiangke/10942397 to your computer and use it in GitHub Desktop.
Save guoxiangke/10942397 to your computer and use it in GitHub Desktop.
按顺序创建365个节点
$time = strtotime('2014-01-01 00:00:00+00:00');
dpm(date('Y-m-d 00:00:00+00:00',$time));
$i=date('z');
dpm($i);
$nodes = array();
for($i;$i<=365;$i++) {
$created =$time + $i* 86400;
$node = new stdClass();
$node->uid = '1';
$node->type = 'grace365';
$node->status = 0;
node_object_prepare($node);
$node->title = '【365】暂无文字版-'.date('m/d',$created);
$node->body[LANGUAGE_NONE][0]['value'] = '永不止息,需要有你,欢迎听写 http://v.tudou.com/_114352882 后发给小永,微信: 649294139!';
$node->language = LANGUAGE_NONE;
$node->created = $created ;
node_save($node);
$node->publish_on = $created;
db_insert('scheduler')->fields(array(
'nid' => $node->nid,
'publish_on' => $node->publish_on,
))->execute();
$nodes[$created] = date('Y-m-d 00:00:00+00:00',$created ).'--'.$node->nid;
}
dpm($nodes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment