钩子文档

get_post_time

💡 云策文档标注

概述

get_post_time 是一个 WordPress 过滤器,用于修改或过滤文章的本地化时间输出。它允许开发者自定义时间格式或调整 GMT 时间设置。

关键要点

  • 过滤器名称:get_post_time
  • 参数:$timestring(格式化的日期字符串或 Unix 时间戳)、$format(时间格式,如 'G'、'U' 或 PHP 日期格式)、$gmt(是否使用 GMT 时间)
  • 返回:应用过滤器后的时间值
  • 相关函数:get_post_time() 用于检索文章的本地化时间
  • 引入版本:WordPress 2.6.0

📄 原文内容

Filters the localized time of the post.

Parameters

$timestring|int
Formatted date string or Unix timestamp if $format is 'U' or 'G'.
$formatstring
Format to use for retrieving the date of the post.
Accepts 'G', 'U', or PHP date format.
$gmtbool
Whether to retrieve the GMT time.

Source

return apply_filters( 'get_post_time', $time, $format, $gmt );

Changelog

Version Description
2.6.0 Introduced.