What’s the difference between get_the_time and get_the_date?

They are, very similar but with some nuances:

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);
}
  1. get_the_date() always works for current global $post, get_the_time() allows you to specify post as argument.

  2. They default to different formats, stored in date_format and time_format options respectively.

  3. They pass output through different filters get_the_date and get_the_time plus lower level get_post_time respectively.

Leave a Comment