本文整理汇总了PHP中Drupal\Core\Datetime\DrupalDateTime::modify方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalDateTime::modify方法的具体用法?PHP DrupalDateTime::modify怎么用?PHP DrupalDateTime::modify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Datetime\DrupalDateTime
的用法示例。
在下文中一共展示了DrupalDateTime::modify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createForumTopics
/**
* Creates a forum topic.
*
* @return string
* The title of the newly generated topic.
*/
protected function createForumTopics($count = 5)
{
$topics = array();
$date = new DrupalDateTime();
$date->modify('-24 hours');
for ($index = 0; $index < $count; $index++) {
// Generate a random subject/body.
$title = $this->randomMachineName(20);
$body = $this->randomMachineName(200);
// Forum posts are ordered by timestamp, so force a unique timestamp by
// changing the date.
$date->modify('+1 minute');
$edit = array('title[0][value]' => $title, 'body[0][value]' => $body, 'created[0][value][date]' => $date->format('Y-m-d'), 'created[0][value][time]' => $date->format('H:i:s'));
// Create the forum topic, preselecting the forum ID via a URL parameter.
$this->drupalPostForm('node/add/forum', $edit, t('Save and publish'), array('query' => array('forum_id' => 1)));
$topics[] = $title;
}
return $topics;
}