• Hi,

    I’m trying to have Last Updated Date show at the top of Blog posts. This is the code I am using. The problem is that the time (hours:minutes) is now showing up next to the last updated date on blog posts.

    I don’t want the time showing. Just the date. I tried removing the bits that indicate “time” (‘h:i a’)- but it didn’t work. I keep googling “How to remove time (stamp) from WordPress posts” etc., but I keep getting articles about removing the date instead. And while the information in the codex is good – I’m just learning PHP so I got a bit turned around.

    Would anyone be able to tell me how to alter this code so only the Last Updated Date shows?

    function wpb_last_updated_date( $content ) {
    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    if ($u_modified_time >= $u_time + 86400) {
    $updated_date = get_the_modified_time(‘F jS, Y’);
    $updated_time = get_the_modified_time(‘h:i a’);
    $custom_content .= ‘<p class=”last-updated”>Last updated on ‘. $updated_date . ‘ at ‘. $updated_time .'</p>’;
    }

    $custom_content .= $content;
    return $custom_content;
    }
    add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

    Thank you for any guidance ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • function wpb_last_updated_date( $content ) {
    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    if ($u_modified_time >= $u_time + 86400) {
    $updated_date = get_the_modified_time(‘F jS, Y’);
    $updated_time = get_the_modified_time(‘h:i a’);
    $custom_content .= ‘<p class=”last-updated”>Last updated on ‘. $updated_date . ‘ at ‘. $updated_time .‘</p>’;
    }

    $custom_content .= $content;
    return $custom_content;
    }
    add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

    remove bold

    Thread Starter Maggie96

    (@maggie96)

    HudsonValleyWebDesign(@jaycbrf)

    It worked! Thank you so much! Based on your response I left a period and an apostrophe behind when I tried it. I’ve got to be more careful.

    Anyway – thank you again for the help – I really appreciate it!

    ??

    Sure thing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Removing time (hours-minutes) from post meta’ is closed to new replies.