get_the_time()
最后更新于:2021-11-27 02:53:37
get_the_time( string$format=”, int|GC_Post$post=null)Retrieve the time at which the post was written.
参数
- $format
-
(string) (Optional) Format to use for retrieving the time the post was written. Accepts ‘G’, ‘U’, or PHP date format. Defaults to the ‘time_format’ option.
Default value: ”
- $post
-
(int|GC_Post) (Optional) GC_Post object or ID. Default is global
$post
object.Default value: null
响应
(string|int|false) Formatted date string or Unix timestamp if $format
is ‘U’ or ‘G’. False on failure.
源文件
文件: gc-includes/general-template.php
function get_the_time( $format = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
$the_time = get_post_time( $_format, false, $post, true );
/**
* Filters the time a post was written.
*
* @since 1.5.0
*
* @param string $the_time The formatted time.
* @param string $format Format to use for retrieving the time the post
* was written. Accepts 'G', 'U', or PHP date format.
* @param int|GC_Post $post GC_Post object or ID.
*/
return apply_filters( 'get_the_time', $the_time, $format, $post );
}