get_the_time
apply_filters( ‘get_the_time’, string $the_time , string $format , int|WP_Post $post )
过滤钩子:过滤一篇文章被写的时间。
Filter Hook: Filters the time a post was written.
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$the_time | (string) | 格式化时间。 |
$format | (string) | 用于检索邮件写入时间的格式。接受“时间格式”选项中指定的“G”、“U”或PHP日期格式值。默认为空。 |
$post | (int | WP_Post) | WP_Post对象或ID。 |
源码(Source)
/** * Retrieve the time at which the post was written. * * @since 1.5.0 * * @param string $d Optional. Format to use for retrieving the time the post * was written. Either 'G', 'U', or php date format defaults * to the value specified in the time_format option. Default empty. * @param int|WP_Post $post WP_Post object or ID. Default is global $post object. * @return false|string Formatted date string or Unix timestamp. False on failure. */ function get_the_time( $d = '', $post = null ) { $post = get_post($post); if ( ! $post ) { return false; } if ( '' == $d ) $the_time = get_post_time(get_option('time_format'), false, $post, true); else $the_time = get_post_time($d, false, $post, true); /** * Filter the time a post was written. * * @since 1.5.0 * * @param string $the_time The formatted time. * @param string $d Format to use for retrieving the time the post was written. * Accepts 'G', 'U', or php date format value specified * in 'time_format' option. Default empty. * @param int|WP_Post $post WP_Post object or ID. */ return apply_filters( 'get_the_time', $the_time, $d, $post ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.5.0 | wp-includes/general-template.php:2548 | 1 | 0 |
get_the_time 为WP2原创文章,链接:https://www.wp2.cn/hook/get_the_time-2/