Forums

[resolved] Get revision time and date (6 posts)

  1. ltrain
    Member
    Posted 9 months ago #

    Hello,

    I'm trying to figure out a way to display the date and time that post or page was last updated.

    I've got code to display the date and time a page was published, and code to display how long ago that is. but is there any way to get the date and time (or how long ago) of the latest revision?

  2. ltrain
    Member
    Posted 9 months ago #

    i'm thinking this might get me somewhere

    <?php
    	if ($post_ID) {
    		if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
    			$last_user = get_userdata($last_id);
    			printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
    		} else {
    			printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
    		}
    	}
    ?>

    but i don't know what to change or where to go from there.

  3. t31os
    Member
    Posted 9 months ago #

  4. ltrain
    Member
    Posted 9 months ago #

    Thanks t31os
    hmm.. that's almost there..

    I'm not very php-savvy though, and i'm looking to display the date and time of only the most recent revision. At the moment, I'm using this code in my Page Template and manually updating the Published date and time

    Last Updated <?php /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?> <?php the_time('l, F jS, Y') ?> (<?php $elixir->timesince() ?> ago).

    which displays as "Last Updated Monday, February 16th, 2009 (1 day, 10 hours ago)." for example.

  5. iridiax
    Member
    Posted 9 months ago #

    Try the_modified_date and/or the_modified_time inside the loop.

    <?php the_modified_date(); ?>

  6. ltrain
    Member
    Posted 9 months ago #

    Works like a treat. Thanks iridiax.

Reply

You must log in to post.

About this Topic