返回介绍

get_post_modified_time()

发布于 2017-09-10 23:55:10 字数 2650 浏览 907 评论 0 收藏 0

get_post_modified_time( string $d = 'U',  bool $gmt = false,  int|WP_Post $post = null,  bool $translate = false )

Retrieve the time at which the post was last modified.


description


参数

$d

(string) (Optional) Format to use for retrieving the time the post was modified. Either 'G', 'U', or php date format.

Default value: 'U'

$gmt

(bool) (Optional) Whether to retrieve the GMT time.

Default value: false

$post

(int|WP_Post) (Optional) WP_Post object or ID. Default is global $post object.

Default value: null

$translate

(bool) (Optional) Whether to translate the time string.

Default value: false


返回值

(string|int|false) Formatted date string or Unix timestamp if $id is 'U' or 'G'. False on failure.


源代码

File: wp-includes/general-template.php

function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
	$post = get_post($post);

	if ( ! $post ) {
		return false;
	}

	if ( $gmt )
		$time = $post->post_modified_gmt;
	else
		$time = $post->post_modified;
	$time = mysql2date($d, $time, $translate);

	/**
	 * Filters the localized time a post was last modified.
	 *
	 * @since 2.8.0
	 *
	 * @param string $time The formatted time.
	 * @param string $d    The date format. Accepts 'G', 'U', or php date format. Default 'U'.
	 * @param bool   $gmt  Whether to return the GMT time. Default false.
	 */
	return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
}

更新日志

Versiondescription
2.0.0Introduced.

相关函数

Uses

  • wp-includes/general-template.php: get_post_modified_time
  • wp-includes/functions.php: mysql2date()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/post.php: get_post()

Used By

  • wp-includes/general-template.php: get_the_modified_date()
  • wp-includes/general-template.php: get_the_modified_time()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文