它们非常相似,但有一些细微差别:
function get_the_date( $d = \'\' ) {
global $post;
$the_date = \'\';
if ( \'\' == $d )
$the_date .= mysql2date(get_option(\'date_format\'), $post->post_date);
else
$the_date .= mysql2date($d, $post->post_date);
return apply_filters(\'get_the_date\', $the_date, $d);
}
function get_the_time( $d = \'\', $post = null ) {
$post = get_post($post);
if ( \'\' == $d )
$the_time = get_post_time(get_option(\'time_format\'), false, $post, true);
else
$the_time = get_post_time($d, false, $post, true);
return apply_filters(\'get_the_time\', $the_time, $d, $post);
}
get_the_date()
始终适用于当前全局$post
, get_the_time()
允许您将post指定为参数。它们默认为不同的格式,存储在date_format
和time_format
选项。
它们将输出通过不同的滤波器get_the_date
和get_the_time
加上较低级别get_post_time
分别地