WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Auto updating Timestamp? (8 posts)

  1. lawtai
    Member
    Posted 8 years ago #

    I run a site for someone where they basically have 1 main post that they continuously update every week. I was wondering if it was possible to have the time stamp auto update itself everytime the post is saved when edited?

  2. Beel
    Member
    Posted 8 years ago #

    You can play around with this: $post->post_modified;

    I use it to display the date and time the page was edited.

  3. Within The Loop:

    date('format', $post->post_modified_gmt + date('Z'));

    That should do it I think. Not 100% sure.

  4. Beel
    Member
    Posted 8 years ago #

    I use something like
    echo date('F jS, Y', strtotime($post->post_modified))

  5. Mmm, that's right, unless you use the MySQL conversion when doing the SELECT, it spits it out as the string still.

    However Beel, if the user's blog time is different from the server time, you code won't work. ;)

    I'd say try:

    // Put this outside The Loop
    $offset = get_option('gmt_offset');

    // Put this inside The Loop
    echo date('format', strtotime($post->post_modified_gmt . ' GMT') + $offset*60);

  6. Beel
    Member
    Posted 8 years ago #

    Right, fortunately the server time is the same - plus I am using it to display page update day and a few hours plus or minus t'ain't important. I just want to know if it was last week or last month. ;-)

    For the anally challenged, I was just going to suggest using:
    $add_seconds = intval(3600 * get_settings('gmt_offset'));
    echo date('F jS, Y h:m a', (strtotime($post->post_modified_gmt) + $add_seconds))

    We must have left lawtai in the dust.

  7. lawtai
    Member
    Posted 8 years ago #

    lol sorry i was away for a few hours there. Thanks again for the help! I'll give this a shot and see how it turns out.

  8. lawtai
    Member
    Posted 8 years ago #

    thanks! it worked great

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags