• Resolved arne23

    (@arne23)


    Like cnn.com, I’d love to have a small text displaying the time and date of the last post at the very top of the page. Something like this: “Updated: 11:08 a.m. EDT (15:08 GMT), September 3, 2005”.

    How can do it?

Viewing 15 replies - 1 through 15 (of 16 total)
  • That is when the page itself was last updated. There is a plugin somewhere which will show when each post was last updated and by whom.

    This bit of code will do it:

    <?php
    $update = get_posts('numberposts=1');
    $postdate = $update[0]->post_date;
    $postdategmt = $update[0]->post_date_gmt;
    echo 'Updated: ' .
    mysql2date('g:j a T ', $postdate) .
    mysql2date('(g:j), ', $postdategmt) .
    mysql2date('F j, Y', $postdate);
    ?>

    This is dependent on the server, so you may have to finnagle the T format string (in 'g:j a T ') if you and your web site’s server are not in the same time zone.

    Thread Starter arne23

    (@arne23)

    Thanks man, that work …BUT not exactly 100% perfect. Can you help me fix that?

    sample ” Updated: 10:1 pm CEST (8:1), September 1, 2005″
    ?°?°?° ?°?°?°

    i not j

    Thread Starter arne23

    (@arne23)

    thanks man

    Oops. Beels correct. How did those j’s get in the format strings…

    Also, you will have to make some more changes to get last updated as the code gets the last posted, not updated… post_modified and post_modified_gmt. One final note, the code pulls the last post and gives the date/time, not the date/time of the last modified post.

    I use this to add a “last modified” to each of my posts:
    <?php echo “<!– Last Modified: $post->post_modified –>\n”; ?>

    I’d love to have a small text displaying the time and date of the last post

    I assumed in this case “updated” referred to the blog as a whole.

    Here’s a Post Updated plugin
    https://guff.szub.net/2005/02/22/post-updated/

    Um, thanks zman. In fact it’s *my* plugin (which I appreciate being plugged!). But it’s intended to work within The Loop. It’s not meant for something like what the OP requested.

    Sorry K, I could have sworn it said “of the last update” and now says “of the last post” (I think it did as now my first post doesn’t make sense). In any event as it currently reads, it seems redundant if one is displaying the date and time of the post anyway.

    Ah, sorry, I see the light now. I’m using your plugin now. Works great!

    >>>This is dependent on the server, so you may have to finnagle the T format string (in ‘g:j a T ‘) if you and your web site’s server are not in the same time zone.<<<

    Not to look like a complete idiot but I’m not sure how to tweak the T format string in order to display the correct time. There is a difference of -5 hours between my home time and the time for my site’s server.

    Could you please point me in the direction to find out how to make this change or let me know what I need to change in the string?

    Many Thanks!

    I *think* that on most servers you have to have shell access to do this.

    <?php echo “$post->post_modified \n”; ?>

    THANKS! This works great in my footer to show the updated post/page time, although I realise thats not what this thread is about!

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘How can I display a “Last update: Time, Day” on my frontpage?’ is closed to new replies.