get_lastpostmodified()获取最后一篇日志的最后修改时间

目录

描述

译文

根据时区检索最后一篇日志的最后修改时间。

默认值是服务器的时区,即GMT和服务器时间的差别。'blog'的值就是最后一篇日志的修改日期。'gmt'则是最后一篇日志修改时的GMT格式日期。

原文

Retrieve last post modified date depending on timezone.

The server timezone is the default and is the difference between GMT and server time. The 'blog' value is just when the last post was modified. The 'gmt' is when the last post was modified in GMT time.

get_lastpostmodified() 描述

用法

<?php get_lastpostmodified$timezone ); ?>

get_lastpostmodified() 用法

参数

$timezone

(string) (可选) The location to get the time. Can be 'gmt', 'blog', or 'server'.

默认值: 'server'

get_lastpostmodified() 参数

返回值

(string) 

The date the post was last modified.

get_lastpostmodified() 返回值

注意

  • 使用到: apply_filters() 调用 'get_lastpostmodified' 过滤器
  • 使用到 global: (mixed) $cache_lastpostmodified Stores the date the last post was last modified.
  • 使用到 global: (object) $wpdb
  • 使用到 global: (integer) $blog_id The Blog ID.

get_lastpostmodified() 注意

历史

添加于 版本: 1.2.0

get_lastpostmodified() 历史

源文件

get_lastpostmodified() 函数的代码位于 wp-includes/post.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Get the timestamp of the last time any post was modified.
 *
 * The server timezone is the default and is the difference between GMT and
 * server time. The 'blog' value is just when the last post was modified. The
 * 'gmt' is when the last post was modified in GMT time.
 *
 * @since 1.2.0
 *
 * @param string $timezone Optional. The timezone for the timestamp. Uses the server's internal timezone.
 *                         Accepts 'server', 'blog', 'gmt'. or 'server'. 'server' uses the server's
 *                         internal timezone. 'blog' uses the `post_modified` field, which proxies
 *                         to the timezone set for the site. 'gmt' uses the `post_modified_gmt` field.
 *                         Default 'server'.
 * @return string The timestamp.
 */
function get_lastpostmodified( $timezone = 'server' ) {
	$lastpostmodified = _get_last_post_time( $timezone, 'modified' );

	$lastpostdate = get_lastpostdate($timezone);
	if ( $lastpostdate > $lastpostmodified )
		$lastpostmodified = $lastpostdate;

	/**
	 * Filter the date the last post was modified.
	 *
	 * @since 2.3.0
	 *
	 * @param string $lastpostmodified Date the last post was modified.
	 * @param string $timezone         Location to use for getting the post modified date.
	 *                                 See {@see get_lastpostmodified()} for accepted `$timezone` values.
	 */
	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
}

get_lastpostmodified() 源文件