本文整理汇总了PHP中get_post_time函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_time函数的具体用法?PHP get_post_time怎么用?PHP get_post_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realistic_time_ago
function realistic_time_ago()
{
global $post;
$date = get_post_time('G', true, $post);
// Array of time period chunks
$chunks = array(array(60 * 60 * 24 * 365, __('year', 'realistic'), __('years', 'realistic')), array(60 * 60 * 24 * 30, __('month', 'realistic'), __('months', 'realistic')), array(60 * 60 * 24 * 7, __('week', 'realistic'), __('weeks', 'realistic')), array(60 * 60 * 24, __('day', 'realistic'), __('days', 'realistic')), array(60 * 60, __('hour', 'realistic'), __('hours', 'realistic')), array(60, __('minute', 'realistic'), __('minutes', 'realistic')), array(1, __('second', 'realistic'), __('seconds', 'realistic')));
if (!is_numeric($date)) {
$time_chunks = explode(':', str_replace(' ', ':', $date));
$date_chunks = explode('-', str_replace(' ', '-', $date));
$date = gmmktime((int) $time_chunks[1], (int) $time_chunks[2], (int) $time_chunks[3], (int) $date_chunks[1], (int) $date_chunks[2], (int) $date_chunks[0]);
}
$current_time = current_time('mysql', $gmt = 0);
$newer_date = strtotime($current_time);
// Difference in seconds
$since = $newer_date - $date;
// Something went wrong with date calculation and we ended up with a negative date.
if (0 > $since) {
return __('sometime', 'realistic');
}
//Step one: the first chunk
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
// Finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0) {
break;
}
}
// Set output var
$output = 1 == $count ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
if (!(int) trim($output)) {
$output = '0 ' . __('seconds', 'realistic');
}
$output .= __(' ago', 'realistic');
return $output;
}
示例2: getPostData
public function getPostData()
{
$fooName = 'bbp_get_' . $this->postType . '_content';
$content = $fooName($this->postId);
$return = array('autor' => array('isCurrentUser' => $this->autorId == get_current_user_id(), 'url' => bp_core_get_user_domain($this->autorId), 'avatar' => bp_core_fetch_avatar(array('item_id' => $autorId, 'height' => $imgSize, 'width' => $imgSize)), 'name' => bbp_get_reply_author_display_name($this->postId)), 'type' => $this->postType, 'attachmentList' => $this->_getAttachmentList(), 'sContent' => bbp_get_reply_content($this->postId), 'id' => $this->postId, 'likes' => 0, 'sDate' => get_post_time('j F ', false, $this->postId, true) . __('at', 'qode') . get_post_time(' H:i', false, $this->postId, true), 'sContentShort' => mb_substr($content, 0, 500), 'sContent' => $content, 'like' => get_post_meta($this->postId, 'likes', true), 'isLiked' => get_post_meta($this->postId, 'like_' . $autorId, true));
return $return;
}
示例3: column_date
function column_date($post)
{
if ('0000-00-00 00:00:00' == $post->post_date) {
$t_time = $h_time = __('Unpublished');
$time_diff = 0;
} else {
$t_time = get_the_time(__('Y/m/d g:i:s A'));
$m_time = $post->post_date;
$time = get_post_time('G', true, $post);
$time_diff = time() - $time;
if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
$h_time = sprintf(__('%s ago'), human_time_diff($time));
} else {
$h_time = mysql2date(__('Y/m/d'), $m_time);
}
}
if ('excerpt' == $mode) {
echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
} else {
echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
}
echo '<br />';
if ('publish' == $post->post_status) {
_e('Published');
} elseif ('future' == $post->post_status) {
if ($time_diff > 0) {
echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
} else {
_e('Scheduled');
}
} else {
_e('Last Modified');
}
}
示例4: sp_get_time
function sp_get_time($post = 0, $format = null)
{
if (null == $format) {
$format = get_option('time_format');
}
return get_post_time($format, false, $post, true);
}
示例5: column_date
function column_date($post)
{
$html = '';
if ('0000-00-00 00:00:00' == $post->post_date) {
$t_time = $h_time = __('Unpublished', 'jetpack');
$time_diff = 0;
} else {
$t_time = date(__('Y/m/d g:i:s A', 'jetpack'), mysql2date('G', $post->post_date));
$m_time = $post->post_date;
$time = get_post_time('G', true, $post);
$time_diff = time() - $time;
if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
$h_time = sprintf(__('%s ago', 'jetpack'), human_time_diff($time));
} else {
$h_time = mysql2date(__('Y/m/d', 'jetpack'), $m_time);
}
}
$html .= '<abbr title="' . esc_attr($t_time) . '">' . esc_html($h_time) . '</abbr>';
$html .= '<br />';
if ('publish' == $post->post_status) {
$html .= esc_html__('Published', 'jetpack');
} elseif ('future' == $post->post_status) {
if ($time_diff > 0) {
$html .= '<strong class="attention">' . esc_html__('Missed schedule', 'jetpack') . '</strong>';
} else {
$html .= esc_html__('Scheduled', 'jetpack');
}
} else {
$html .= esc_html__('Last Modified', 'jetpack');
}
return $html;
}
示例6: maybe_add_robots
function maybe_add_robots()
{
global $post;
if (is_singular() && bbp_is_topic($post->ID) && bbp_is_topic_closed($post->ID) && time() - get_post_time('U', true, $post) > YEAR_IN_SECONDS) {
echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
}
}
示例7: apip_sameday_post
/**
* 作用: 显示历史相同日文章
* 来源: 自产
* URL:
*/
function apip_sameday_post()
{
global $wpdb;
$month = get_post_time('m');
$day = get_post_time('j');
$id = get_the_ID();
global $apip_options;
$limit = $apip_options['local_definition_count'] ? $apip_options['local_definition_count'] : 5;
$ret = '<ul class = "apip-history-content">';
$sql = "select ID, year(post_date) as h_year, post_title FROM \r\n {$wpdb->posts} WHERE post_password = '' AND post_type = 'post' AND post_status = 'publish' \r\n AND month(post_date)='{$month}' AND day(post_date)='{$day}' AND ID != '{$id}' \r\n order by post_date LIMIT {$limit}";
$history_posts = $wpdb->get_results($sql);
$rcount = $limit - count($history_posts);
if ($rcount > 0) {
$random_posts = apip_random_post(get_the_ID(), $rcount);
}
foreach ($history_posts as $history_post) {
$ret = $ret . '<li><span>' . $history_post->h_year . ': <span><a class="sameday-post" href="' . get_permalink($history_post->ID) . '">';
$ret = $ret . $history_post->post_title . '</a></li>';
}
if ($rcount > 0) {
foreach ($random_posts as $random_post) {
$ret = $ret . '<li><span>RAND: </span><a class="sameday-post" href="' . get_permalink($random_post->ID) . '">';
$ret = $ret . $random_post->post_title . '</a></li>';
}
}
$ret = $ret . '</ul>';
return $ret;
}
示例8: get_time
/**
* WP filter handler. Returns:
* - Relative date.
* - Absolute date with `$this->wp_fallback` format, if relative is not suitable.
*
* @param int $wp_time - Timestamp?
* @return string
*/
public function get_time($wp_time)
{
global $post;
$time = get_post_time('U', true, $post);
$diff = $this->diff($time, null, true, false, $this->wp_fallback);
return !is_int($diff) ? $diff : $wp_time;
}
示例9: widget
function widget($args, $instance)
{
global $post;
/* PRINT THE WIDGET */
extract($args, EXTR_SKIP);
$title = !empty($instance['title']) ? $instance['title'] : '';
if (!is_single()) {
return;
}
echo $before_widget;
if (!empty($title)) {
echo $before_title;
echo $title;
echo $after_title;
}
$name = get_the_author_meta('display_name', $post->post_author);
echo '<div class="large-icons">';
echo '<ul>';
edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'myThemes'), '<li>', '</li>');
echo '<li><a href="' . get_day_link(get_post_time('Y', false, $post->ID), get_post_time('m', false, $post->ID), get_post_time('d', false, $post->ID)) . '">';
echo '<time datetime="' . get_post_time('Y-m-d', false, $post->ID) . '"><i class="icon-calendar"></i>' . get_post_time(get_option('date_format'), false, $post->ID) . '</time></a></li>';
echo '<li><a href="' . get_author_posts_url($post->post_author) . '" title="' . __('Writed by ', 'myThemes') . ' ' . $name . '"><i class="icon-user-5"></i>' . $name . '</a></li>';
if ($post->comment_status == 'open') {
$nr = get_comments_number($post->ID);
if ($nr == 1) {
$comments = $nr . ' ' . __('Comment', 'myThemes');
} else {
$comments = $nr . ' ' . __('Comments', 'myThemes');
}
echo '<li><a href="' . get_comments_link($post->ID) . '"><i class="icon-comment"></i>' . $comments . '</a></li>';
}
echo '</ul>';
echo '</div>';
echo $after_widget;
}
示例10: write_here_time_edit
function write_here_time_edit($edit = 1, $for_post = 1, $tab_index = 0, $multi = 0)
{
global $wp_locale, $comment;
// Get post ID from URL and assign it to 'get_post' to get post info
$post_id = $_REQUEST['post'];
$post = get_post($post_id);
if ($for_post) {
$edit = !(in_array($post->post_status, array('draft', 'pending')) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt));
}
$tab_index_attribute = '';
if ((int) $tab_index > 0) {
$tab_index_attribute = " tabindex=\"{$tab_index}\"";
}
// todo: Remove this?
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
// Assign published date of posts instead of current time
$time_adj = get_post_time('U', true, $post_id);
$post_date = $post->post_date;
$jj = $edit ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj);
$mm = $edit ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj);
$aa = $edit ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj);
$hh = $edit ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj);
$mn = $edit ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj);
$ss = $edit ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj);
$cur_jj = gmdate('d', $time_adj);
$cur_mm = gmdate('m', $time_adj);
$cur_aa = gmdate('Y', $time_adj);
$cur_hh = gmdate('H', $time_adj);
$cur_mn = gmdate('i', $time_adj);
$month = '<label><span class="screen-reader-text">' . __('Month') . '</span><select ' . ($multi ? '' : 'id="mm" ') . 'name="mm"' . $tab_index_attribute . ">\n";
for ($i = 1; $i < 13; $i = $i + 1) {
$monthnum = zeroise($i, 2);
$monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i));
$month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected($monthnum, $mm, false) . '>';
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
$month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext) . "</option>\n";
}
$month .= '</select></label>';
$day = '<label><span class="screen-reader-text">' . __('Day') . '</span><input type="text" ' . ($multi ? '' : 'id="jj" ') . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
$year = '<label><span class="screen-reader-text">' . __('Year') . '</span><input type="text" ' . ($multi ? '' : 'id="aa" ') . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>';
$hour = '<label><span class="screen-reader-text">' . __('Hour') . '</span><input type="text" ' . ($multi ? '' : 'id="hh" ') . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
$minute = '<label><span class="screen-reader-text">' . __('Minute') . '</span><input type="text" ' . ($multi ? '' : 'id="mn" ') . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
echo '<div class="timestamp-wrap">';
/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
printf(__('%1$s %2$s, %3$s @ %4$s:%5$s'), $month, $day, $year, $hour, $minute);
echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
if ($multi) {
return;
}
echo "\n\n";
$map = array('mm' => array($mm, $cur_mm), 'jj' => array($jj, $cur_jj), 'aa' => array($aa, $cur_aa), 'hh' => array($hh, $cur_hh), 'mn' => array($mn, $cur_mn));
foreach ($map as $timeunit => $value) {
list($unit, $curr) = $value;
echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
$cur_timeunit = 'cur_' . $timeunit;
echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
}
}
示例11: get_post_data
function get_post_data($post_object)
{
global $post;
$post = $post_object;
setup_postdata($post);
$post_class = get_post_class();
$post_data = array('author' => get_the_author(), 'author_url' => get_author_posts_url(get_the_author_meta('ID')), 'classes' => join(' ', $post_class), 'content' => get_the_content(), 'date' => get_the_date(), 'datetime' => get_post_time('c', true), 'excerpt' => get_the_excerpt(), 'json_url' => '/wp-json/wp/v2/posts/' . get_the_ID(), 'title' => get_the_title(), 'link' => str_replace(home_url(), '', get_the_permalink()));
return $post_data;
}
示例12: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Posts', 'heal') : $instance['title'], $instance, $this->id_base);
$count = empty($instance['count']) ? 5 : $instance['count'];
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul class="popular-post">
<?php
$pc = new WP_Query('orderby=comment_count&posts_per_page=' . $count . '');
while ($pc->have_posts()) {
$pc->the_post();
?>
<li>
<?php
if (has_post_thumbnail()) {
the_post_thumbnail('widget-thumb');
} else {
echo '<img src="' . get_template_directory_uri() . '/assets/images/no-img-thumb.jpg">';
}
?>
<a href="<?php
the_permalink();
?>
" title="<?php
the_title();
?>
"><?php
the_title();
?>
</a> <br/ >
<time class="post-meta-element" datetime="<?php
echo get_post_time('U', true);
?>
"><?php
echo get_the_date('j F, Y');
?>
</time> | <span class="popular-post-comment"> <?php
comments_popup_link('No Comments;', '1 Comment', '% Comments');
?>
</span>
</li>
<?php
}
?>
<?php
wp_reset_query();
?>
</ul><!-- /.latest-post -->
<?php
echo $after_widget;
}
示例13: listing_page__get_the_date
public function listing_page__get_the_date($the_date, $d = '')
{
if (!$this->listing_id) {
return $the_date;
}
if (!$d) {
$d = get_option('date_format');
}
//remove_filter( 'get_the_date', array( &$this, 'listing_page__get_the_date' ), 10, 2 );
return get_post_time($d, $this->listing_id);
}
示例14: simple_life_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function simple_life_posted_on()
{
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
if (get_the_time('U') !== get_the_modified_time('U')) {
$time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
$posted_on = sprintf('%s', '<i class="fa fa-calendar" aria-hidden="true"></i> <a href="' . esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))) . '" rel="bookmark">' . $time_string . '</a>');
$byline = sprintf('<i class="fa fa-user" aria-hidden="true"></i> %s', '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>';
// WPCS: XSS OK.
}
示例15: dynamictime
function dynamictime()
{
global $post;
$date = $post->post_date;
$time = get_post_time('G', true, $post);
$mytime = time() - $time;
if ($mytime > 0 && $mytime < 24 * 60 * 60) {
$mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
} else {
$mytimestamp = date(get_option('date_format'), strtotime($date));
}
return $mytimestamp;
}