WordPress.org

Ready to get started?Download WordPress

Forums

How do I display a remote file's date last modified? (4 posts)

  1. sleeplessinDC
    Member
    Posted 1 year ago #

    On my current page, I have a link to the Volunteer Openings page. I'd like to add the date that page was last modified at the end of the link. I tried using $remote and $last_modifed but I get a date in 1970: Volunteer Openings Updated: January 1, 1970. It should be November 2, 2012.

    Here is the code I'm using, what am I doing wrong?

    <?php
    /* e.g.  volunteer openings Updated: November 2, 2012 */
    $response = wp_remote_get('./volunteers/volunteer-openings/');
    $last_modified = wp_remote_retrieve_body( $response, 'last-modified' );
        echo 'Updated: '. date('F j, Y.', last-modified);
    ?>

    Thanks for your help.

  2. Max
    Member
    Posted 1 year ago #

    Thats the Unix epoch, which means that $last_modified is evaluating to 0.

    There is a template tage to do this ... that must be run from the loop... refer to the codex at http://codex.wordpress.org/Function_Reference/the_modified_date

  3. sleeplessinDC
    Member
    Posted 1 year ago #

    Thanks but how do I use that? I replaced wp_remote_retrieve_body with get_the_modified_date and I still get the January 1, 1970 date. Then I tried:

    <?php
    /* e.g.  volunteer openings Updated: November 2, 2012 */
    $response = wp_remote_get('./volunteers/volunteer-openings/');
    $modified_date = get_the_modified_date( $response, 'modified-date' );
        echo 'Updated: '. date('F j, Y.', modified-date);
    ?>

    and get Catchable fatal error: Object of class WP_Error could not be converted to string in .../wp-includes/functions.php on line 111

  4. sleeplessinDC
    Member
    Posted 1 year ago #

    Is it possible to get the last modified date of a remote page to show on a different page? I know how to display the latest date for a current page but not for how to display one with a link to a different page. For example, to use in a What's New list--list specific pages and show when they were last updated.

Topic Closed

This topic has been closed to new replies.

About this Topic