get_post_modified_time() - WordPress 函数参考中文文档

返回介绍

get_post_modified_time()

发布于 2017-09-10 字数2652 浏览 769 评论 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.


描述


参数

$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 );
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!