get_the_time()
get_the_time( string $format = ”, int|WP_Post $post = n…
get_the_time( string $format = ”, int|WP_Post $post = null )
检索写邮件的时间。
Retrieve the time at which the post was written.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $format | (string) | 可选 | 用于检索邮件写入时间的格式。“G”、“U”或PHP日期格式默认为time_format选项中指定的值。 |
| $post | (int | WP_Post) | 可选 | WP_Post object或ID。默认值为全局$Post object。 |
返回(Return)
(string|int|false)格式化的日期string或Unix时间戳(string|int|false)。失败时为False。
源码(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:2524 | 6 | 5 |
笔记(Notes)
基本示例
获取Unix时间戳
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!