Forums

[resolved] How can I display a "Last update: Time, Day" on my frontpage? (17 posts)

  1. Arne23
    Member
    Posted 6 years ago #

    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?

  2. Beel
    Member
    Posted 6 years ago #

    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.

  3. Kafkaesqui
    Moderator
    Posted 6 years ago #

    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.

  4. Arne23
    Member
    Posted 6 years ago #

    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"
    °°° °°°

  5. Beel
    Member
    Posted 6 years ago #

    i not j

  6. Arne23
    Member
    Posted 6 years ago #

    thanks man

  7. Kafkaesqui
    Moderator
    Posted 6 years ago #

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

  8. Beel
    Member
    Posted 6 years ago #

    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"; ?>

  9. Kafkaesqui
    Moderator
    Posted 6 years ago #

    "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.

  10. zman
    Member
    Posted 6 years ago #

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

  11. Kafkaesqui
    Moderator
    Posted 6 years ago #

    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.

  12. Beel
    Member
    Posted 6 years ago #

    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.

  13. zman
    Member
    Posted 6 years ago #

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

  14. pwtgirl
    Member
    Posted 5 years ago #

    >>>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!

  15. vkaryl
    Member
    Posted 5 years ago #

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

  16. ninjaboy
    Member
    Posted 5 years ago #

    <?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!

  17. ninjaboy
    Member
    Posted 5 years ago #

    I played around with this quite a bit - please see the solution I posted at

    http://wordpress.org/support/topic/63955?replies=9#post-494372

    <b>Kafkaesqui</b> - your plugin is great and I still currently use it on one of my sites - I do highly recommend it to anyone that is not comfortable with a bit of coding. However, I needed more control over the output. It would be great if you could control the strings of text before/after the stats through an admin control panel... if I had the time I'd do it myself, but I am totally stacked out with work for the forseeable future!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.