• Resolved ltrain

    (@ltrain)


    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter ltrain

    (@ltrain)

    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.

    Thread Starter ltrain

    (@ltrain)

    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.

    Try the_modified_date and/or the_modified_time inside the loop.

    <?php the_modified_date(); ?>

    Thread Starter ltrain

    (@ltrain)

    Works like a treat. Thanks iridiax.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get revision time and date’ is closed to new replies.