本文整理汇总了PHP中format_date函数的典型用法代码示例。如果您正苦于以下问题:PHP format_date函数的具体用法?PHP format_date怎么用?PHP format_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_date函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$result = '';
if (!empty($configdata['artefactids'])) {
$artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
WHERE a.artefacttype = \'blogpost\'
AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT owner from {view} WHERE id = ?)
ORDER BY a.ctime DESC
LIMIT 10', array($instance->get('view'))))) {
$mostrecent = array();
}
// format the dates
foreach ($mostrecent as &$data) {
$data->displaydate = format_date($data->ctime);
}
$smarty = smarty_core();
$smarty->assign('mostrecent', $mostrecent);
$smarty->assign('view', $instance->get('view'));
$result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
}
return $result;
}
示例2: testTicketCreation
/**
* Creates a "ticket" support_ticket and verifies its consistency in the database.
*/
function testTicketCreation()
{
$ticket_type_storage = \Drupal::entityManager()->getStorage('support_ticket_type');
// Test /support_ticket/add page with only one content type.
$this->drupalGet('support_ticket/add');
$this->assertResponse(200);
$this->assertUrl('support_ticket/add/ticket');
// Create a ticket.
$edit = array();
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$edit['field_priority'] = '120';
// 120 = 'high'
$edit['field_state'] = 'inactive';
$this->drupalPostForm('support_ticket/add/ticket', $edit, t('Save'));
// Check that the ticket has been created.
$this->assertRaw(t('@post %title has been created.', array('@post' => 'Ticket', '%title' => $edit['title[0][value]'])), 'Ticket created.');
// Check that the support_ticket exists in the database.
$ticket = $this->supportTicketGetTicketByTitle($edit['title[0][value]']);
$this->assertTrue($ticket, 'Ticket found in database.');
// View ticket to test single ticket output.
$this->drupalGet('support_ticket/' . $ticket->id());
// Base "Submitted by..." heading.
$this->assertText($ticket->getOwner()->getUsername());
$this->assertText(format_date($ticket->getCreatedTime()));
// Check field display output for basic ticket fields.
$elements = $this->cssSelect("div.field--name-field-priority div.field__item:contains('high')");
$this->assertEqual(count($elements), 1, 'Priority was set correctly.');
$elements = $this->cssSelect("div.field--name-field-state div.field__item:contains('inactive')");
$this->assertEqual(count($elements), 1, 'State was set correctly.');
}
示例3: autoLogin
public function autoLogin()
{
if (cookie('token')) {
$token = cookie('token');
$userId = $token['userId'];
if (!is_numeric($userId)) {
return 0;
}
$User = D('User');
$user = $User->find($userId);
if ($user['userId'] != $userId) {
return 0;
}
if ($token['verify'] != sha1(md5($user['password']))) {
return 0;
}
session('userId', $user['userId']);
session('userName', $user['userName']);
session('icon', $user['icon']);
session('email', $user['email']);
session('signature', $user['signature']);
session('score', $user['score']);
session('registerTime', format_date($user['registerTime']));
session('lastLoginTime', format_date($user['lastLoginTime']));
//更新上次登录时间
$User->where("userId={$userId}")->setField('lastLoginTime', date('Y-m-d H:i:s', time()));
cookie('token', $token, 864000);
return 1;
} else {
return 0;
}
}
开发者ID:AlexanderFeng,项目名称:a-simple-question-and-answer-website,代码行数:32,代码来源:AutoLoginController.class.php
示例4: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
if (!empty($configdata['feedid'])) {
$data = get_record('blocktype_externalfeed_data', 'id', $configdata['feedid'], null, null, null, null, 'id,url,link,title,description,content,' . db_format_tsfield('lastupdate') . ',image');
$data->content = unserialize($data->content);
$data->image = unserialize($data->image);
// only keep the number of entries the user asked for
$chunks = array_chunk($data->content, isset($configdata['count']) ? $configdata['count'] : 10);
$data->content = $chunks[0];
// Attempt to fix relative URLs in the feeds
if (!empty($data->image['link'])) {
$data->description = preg_replace('/src="(\\/[^"]+)"/', 'src="' . $data->image['link'] . '$1"', $data->description);
foreach ($data->content as &$entry) {
$entry->description = preg_replace('/src="(\\/[^"]+)"/', 'src="' . $data->image['link'] . '$1"', $entry->description);
}
}
$smarty = smarty_core();
$smarty->assign('title', $data->title);
$smarty->assign('description', $data->description);
$smarty->assign('url', $data->url);
// 'full' won't be set for feeds created before 'full' support was added
$smarty->assign('full', isset($configdata['full']) ? $configdata['full'] : false);
$smarty->assign('link', $data->link);
$smarty->assign('entries', $data->content);
$smarty->assign('feedimage', self::make_feed_image_tag($data->image));
$smarty->assign('lastupdated', get_string('lastupdatedon', 'blocktype.externalfeed', format_date($data->lastupdate)));
return $smarty->fetch('blocktype:externalfeed:feed.tpl');
}
return '';
}
示例5: getMembers
function getMembers($incl_archived = TRUE, $order_by = NULL)
{
$db =& $GLOBALS['db'];
$sql = 'SELECT p.*, gm.membership_status AS membership_status_id, ms.label as membership_status, gm.created as joined_group, c.name as congregation
FROM person_group_membership gm
JOIN person p ON gm.personid = p.id
';
if ($order_by != NULL) {
$sql .= '
JOIN family f ON f.id = p.familyid
';
}
$sql .= '
LEFT JOIN congregation c ON c.id = p.congregationid
LEFT JOIN person_group_membership_status ms ON ms.id = gm.membership_status
WHERE gm.groupid = ' . $db->quote((int) $this->id) . '
';
if (!$incl_archived) {
$sql .= ' AND p.status <> "archived"
';
}
if ($order_by == NULL) {
$order_by = 'ms.rank, p.last_name, p.first_name';
} else {
$order_by = preg_replace("/(^|[^.])status(\$| |,)/", '\\1p.status\\2', $order_by);
}
$sql .= 'ORDER BY ' . $order_by;
$res = $db->queryAll($sql, null, null, true);
check_db_result($res);
foreach ($res as $k => &$v) {
$v['joined_group'] = format_date($v['joined_group']);
}
return $res;
}
示例6: folder_contents
/**
* Get all folders and files within a folder
*
* @param int $parent The id of this folder
* @return array
*
**/
public static function folder_contents($parent = 0, $type = null)
{
// they can also pass a url hash such as #foo/bar/some-other-folder-slug
if (!is_numeric($parent)) {
$segment = explode('/', trim($parent, '/#'));
$result = ci()->file_folders_m->get_by('slug', array_pop($segment));
$parent = $result ? $result->id : 0;
}
$folders = ci()->file_folders_m->where('parent_id', $parent)->where('hidden', 0)->order_by('sort')->get_all();
// $files = ci()->file_m->where(array('folder_id' => $parent))
// ->order_by('sort')
// ->get_all();
$files = ci()->file_m->where(array('folder_id' => $parent, 'type' => $type))->order_by('sort')->get_all();
// let's be nice and add a date in that's formatted like the rest of the CMS
if ($folders) {
foreach ($folders as &$folder) {
$folder->formatted_date = format_date($folder->date_added);
$folder->file_count = ci()->file_m->count_by('folder_id', $folder->id);
}
}
if ($files) {
ci()->load->library('keywords/keywords');
foreach ($files as &$file) {
$file->keywords_hash = $file->keywords;
$file->keywords = ci()->keywords->get_string($file->keywords);
$file->formatted_date = format_date($file->date_added);
}
}
return Files::result(true, null, null, array('folder' => $folders, 'file' => $files, 'parent_id' => $parent));
}
示例7: sca_responsive_sort_repertoire
function sca_responsive_sort_repertoire($results)
{
// dpm($results);
$sorted = array('remarks' => array());
$x = 0;
$doubled_entries = array(2425 => 2425, 2427 => 2427);
foreach ($results as $entry) {
// Views'as kažkodėl dubliuoja visus rezultatus, neturėjau laiko aiškintis kodėl, tad tiesiog atfiltruoju kas antrą.
if ($x % 2 !== 0 || in_array($entry->nid, $doubled_entries)) {
// $x++;
// continue;
}
// O kai kurie rezultatai (filmų rinkiniai), kažkodėl atrenkami po 4 kartus...
if (in_array($entry->node_field_data_field_filmas_nid, $doubled_entries)) {
// unset($doubled_entries[$entry->node_field_data_field_filmas_nid]);
// $x++;
// continue;
}
$x++;
$director = !empty($entry->field_field_motrezisierius) ? $entry->field_field_motrezisierius[0]['rendered']['#markup'] : '';
$director .= !empty($entry->field_field_vyrrezisierius) ? $entry->field_field_vyrrezisierius[0]['rendered']['#markup'] : '';
$director .= !empty($entry->field_field_daugrezisieriu) ? $entry->field_field_daugrezisieriu[0]['rendered']['#markup'] : '';
$sorted[$entry->taxonomy_term_data_field_data_field_vieta_tid][] = array('nid' => $entry->node_field_data_field_filmas_nid, 'entry_nid' => $entry->nid, 'alias' => drupal_get_path_alias('node/' . $entry->node_field_data_field_filmas_nid), 'time' => $entry->field_field_data[0]['rendered']['#markup'], 'small_date' => format_date(strtotime($entry->field_field_data_1[0]['raw']['value']), 'kalendoriaus'), 'title' => $entry->field_title_field[0]['rendered']['#markup'], 'title_lt' => $entry->node_field_data_field_filmas_title, 'title_en' => isset($entry->field_field_engpav[0]) ? $entry->field_field_engpav[0]['rendered']['#markup'] : NULL, 'year' => isset($entry->field_field_metaiirtrukme[0]) ? $entry->field_field_metaiirtrukme[0]['rendered']['#markup'] : NULL, 'country' => !empty($entry->field_field_salis) ? $entry->field_field_salis[0]['rendered']['#markup'] : NULL, 'director' => $director, 'color' => !empty($entry->field_field_programos_spalva) ? $entry->field_field_programos_spalva[0]['rendered']['#markup'] : 'fff', 'extra_text' => !empty($entry->field_field_extra_text) ? $entry->field_field_extra_text[0]['rendered']['#markup'] : NULL, 'program_name' => !empty($entry->field_name_field) ? $entry->field_name_field[0]['rendered']['#markup'] : '', 'remarks' => !empty($entry->field_field_rep_iraso_pastabos) ? $entry->field_field_rep_iraso_pastabos[0]['rendered']['#markup'] : '');
if (!empty($entry->field_field_rep_iraso_pastabos)) {
$sorted['remarks'][] = array('time' => $entry->field_field_data_2[0]['rendered']['#markup'], 'place' => $entry->field_field_pilnas_pavadinimas[0]['rendered']['#markup'], 'remark' => $entry->field_field_rep_iraso_pastabos[0]['rendered']['#markup']);
}
}
// dpm($sorted);
return $sorted;
}
示例8: alternator_preprocess_node
function alternator_preprocess_node(&$vars)
{
if (in_array($vars['type'], array('article', 'event'))) {
unset($vars['links']);
unset($vars['field_library_ref_rendered']);
unset($vars['field_list_image_rendered']);
unset($vars['field_content_images_rendered']);
unset($vars['field_file_attachments_rendered']);
#var_dump($vars);
$vars['submitted'] = format_date($vars['created'], 'large', 'Europe/Copenhagen', 'dk');
if ($vars['type'] == 'event') {
$vars['submitted'] = $vars['node']->field_datetime[0]['view'];
$vars['price'] = $vars['node']->field_entry_price[0]['view'];
}
/*
* 'Unprint' some node elements and rerender. Not really the right
* way to handle this, but legacy code simply grabbed
* $node->content['body']['#value'], and redoing it properly would
* require updating of too many existing sites.
*/
unset($vars['node']->content['#printed']);
unset($vars['node']->content['body']['#printed']);
if (isset($vars['node']->content['place2book_infolink'])) {
unset($vars['node']->content['place2book_infolink']['#printed']);
}
$vars['content'] = drupal_render($vars['node']->content);
}
}
示例9: testNodeCreation
/**
* Creates a "Basic page" node and verifies its consistency in the database.
*/
function testNodeCreation()
{
$node_type_storage = \Drupal::entityManager()->getStorage('node_type');
// Test /node/add page with only one content type.
$node_type_storage->load('article')->delete();
$this->drupalGet('node/add');
$this->assertResponse(200);
$this->assertUrl('node/add/page');
// Create a node.
$edit = array();
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the Basic page has been created.
$this->assertText(t('@post @title has been created.', array('@post' => 'Basic page', '@title' => $edit['title[0][value]'])), 'Basic page created.');
// Verify that the creation message contains a link to a node.
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
$this->assert(isset($view_link), 'The message area contains a link to a node');
// Check that the node exists in the database.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertTrue($node, 'Node found in database.');
// Verify that pages do not show submitted information by default.
$this->drupalGet('node/' . $node->id());
$this->assertNoText($node->getOwner()->getUsername());
$this->assertNoText(format_date($node->getCreatedTime()));
// Change the node type setting to show submitted by information.
/** @var \Drupal\node\NodeTypeInterface $node_type */
$node_type = $node_type_storage->load('page');
$node_type->setDisplaySubmitted(TRUE);
$node_type->save();
$this->drupalGet('node/' . $node->id());
$this->assertText($node->getOwner()->getUsername());
$this->assertText(format_date($node->getCreatedTime()));
}
示例10: display
function display()
{
if (!$_POST and $this->mdl_mcb_data->setting('dashboard_total_paid_cutoff_date')) {
$this->mdl_mcb_data->set_setting('dashboard_total_paid_cutoff_date', format_date($this->mdl_mcb_data->setting('dashboard_total_paid_cutoff_date')));
}
$this->load->view('settings');
}
示例11: add_comment_feeditem
function add_comment_feeditem($item)
{
global $db, $rss_items, $atom_items, $Cfg, $Weblogs, $Current_weblog, $Allow_RSS, $Paths;
if (!siteurl_isset()) {
$weblog = $Paths['host'] . $Paths['pivot_url'];
} else {
$weblog = $Weblogs[$Current_weblog]['siteurl'];
}
$entry = $db->read_entry($item['code']);
$link = make_fileurl($item['uid'], "", "");
$title = $db->entry['title'];
$date = format_date($item['date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . rss_offset();
$description = htmlspecialchars(strip_tags($item['comment']));
$description = str_replace(" ", " ", $description);
$id = safe_string($item["name"], TRUE) . "-" . format_date($item["date"], "%ye%%month%%day%%hour24%%minute%");
$tag = str_replace("_", "", strtolower(safe_string($Cfg['sitename'], TRUE))) . "," . date("Y") . ":" . $id;
// make sure description is not too long..
if (isset($Weblogs[$Current_weblog]['rss_full']) && $Weblogs[$Current_weblog]['rss_full'] == 0) {
// don't put anything in the content.
$content = "";
} else {
// put the introduction and body in the content..
$content = str_replace(" ", " ", $introduction . $body);
}
if (isemail($item['email'])) {
$email = "\n<email>" . $item['email'] . "</email>";
} else {
$email = "";
}
if (isurl($item['url'])) {
if (strpos($item["url"], "ttp://") < 1) {
$item["url"] = "http://" . $item["url"];
}
$url = "\n<uri>" . $item['url'] . "</uri>";
} else {
$url = "";
}
$atom_item = '
<entry>
<title>%author% on %title%</title>
<link rel="alternate" type="text/html" href="%link%#%id%"/>
<updated>%date%</updated>
<published>%date%</published>
<id>tag:%tag%</id>
<summary type="text">%description%</summary>
<content type="html" xml:lang="%lang%" xml:base="%link%">
<![CDATA[
%content%
]]>
</content>
<author>
<name>%author%</name>%url%%email%
</author>
</entry>
';
$from = array("%title%", "%link%", "%id%", "%description%", "%content%", "%author%", "%guid%", "%date%", "%tag%", "%lang%", "%url%", "%email%");
$to = array(htmlspecialchars(strip_tags($entry['title'])), $link, $id, RelativeToAbsoluteURLS($description), trim(comment_format($item['comment'])), htmlspecialchars(unentify($item['name'])), $item['uid'] . "@" . $weblog, $date, $tag, snippet_lang(), $url, $email);
$atom_item = str_replace($from, $to, $atom_item);
$atom_items[$date] = $atom_item;
}
示例12: snippet_posted_by
function snippet_posted_by($code, $with_tags = true)
{
$params = array();
// Contributor parameter is set.
if ($code->getUserId()) {
$params['%contributor%'] = link_to($code->getContributor(), 'user/viewProfile?username=' . $code->getContributor());
} else {
$params['%contributor%'] = $code->getContributor();
}
// Date parameter is set.
$params['%date%'] = format_date($code->getCreatedAt());
if ($with_tags) {
// Tags parameter is set.
$tag_links = array();
$tags = explode(', ', $code->getTag());
for ($i = 0; $i < count($tags); $i++) {
if ($tags[$i]) {
$tag_links[$i] = link_to($tags[$i], 'tag/show?tag=' . $tags[$i]);
}
}
$params['%tags%'] = implode(', ', $tag_links);
}
if (isset($params['%tags%'])) {
return __('posted by %contributor% on %date% with tags %tags%', $params);
} else {
return __('posted by %contributor% on %date%', $params);
}
}
示例13: jeugdwerksupport_preprocess_node
/**
* Override or insert variables into the node template.
*/
function jeugdwerksupport_preprocess_node(&$variables)
{
$node = $variables['node'];
// Add template suggestions
if (!$variables['page']) {
if ($variables['teaser']) {
$variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__teaser';
$variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->nid . '__teaser';
$variables['theme_hook_suggestions'][] = 'node__teaser';
}
}
// Add class 'node-full'
if ($variables['view_mode'] == 'full' && node_is_page($node)) {
$variables['classes_array'][] = 'node-full';
}
// Set custom date format
$variables['date'] = format_date($node->created, 'custom', 'F jS Y');
// Add summary variable
if ($variables['view_mode'] == 'full') {
$items = field_get_items('node', $node, 'body', $node->language);
if ($items) {
// If there's a single summary, just set the summary variable
if (count($items) == 1) {
$variables['summary'] = $items[0]['summary'];
} else {
foreach ($items as $item) {
$variables['summary'][] = $item['summary'];
}
}
}
}
}
示例14: generete_dates
/**
* Формирует заголовок таблицы
* @return [type] [description]
*/
function generete_dates()
{
$monday = time() - (date("N") - 1) * 24 * 60 * 60;
$monday = strtotime(format_date($monday));
$days_array = array(0 => $monday, 1 => strtotime("+1 day", $monday), 2 => strtotime("+2 day", $monday), 3 => strtotime("+3 day", $monday), 4 => strtotime("+4 day", $monday), 5 => strtotime("+5 day", $monday), 6 => strtotime("+6 day", $monday));
return $days_array;
}
示例15: projectsStatus
/**
* LOCALE_TRANSLATION_REMOTE
* and LOCALE_TRANSLATION_LOCAL indicate available new translations,
* LOCALE_TRANSLATION_CURRENT indicate that the current translation is them
* most recent.
*/
protected function projectsStatus()
{
$status_report = [];
$status = locale_translation_get_status();
foreach ($status as $project_id => $project) {
foreach ($project as $langcode => $project_info) {
$info = '';
if ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
$local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : null;
$remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : null;
$local_age = $local->timestamp ? format_date($local->timestamp, 'html_date') : '';
$remote_age = $remote->timestamp ? format_date($remote->timestamp, 'html_date') : '';
if ($local_age >= $remote_age) {
$info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
} else {
$info = $this->trans('commands.locale.translation.status.messages.translation-project-available');
}
} elseif ($project_info->type == LOCALE_TRANSLATION_CURRENT) {
$info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
} else {
$local_age = '';
$remote_age = '';
$info = $this->createInfoString($project_info);
}
$status_report[$langcode][] = [$project_info->name, $project_info->version, $local_age, $remote_age, $info];
}
}
return $status_report;
}