0

I'm trying to retrieve the last modified information of a webpage? I don't even know if php would do it or would javascript be better better for this. I've tried document.lastmodified with java script but that does not help much.

I've noticed that in firefox ->tools->page info gives me the exact date/time of any webpage when was it last modified. But I don't know how to get that info displayed about any website on my webpage.

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by diafol
0

but how/where do I enter the webpage's address whose date/time of last update i'm looking for?

0

Got this from the pHp manual:

<?php

// get remote file last modification date (returns unix timestamp)
function GetRemoteLastModified( $uri )
{
    // default
    $unixtime = 0;
    
    $fp = fopen( $uri, "r" );
    if( !$fp ) {return;}
    
    $MetaData = stream_get_meta_data( $fp );
        
    foreach( $MetaData['wrapper_data'] as $response )
    {
        // case: redirection
        if( substr( strtolower($response), 0, 10 ) == 'location: ' )
        {
            $newUri = substr( $response, 10 );
            fclose( $fp );
            return GetRemoteLastModified( $newUri );
        }
        // case: last-modified
        elseif( substr( strtolower($response), 0, 15 ) == 'last-modified: ' )
        {
            $unixtime = strtotime( substr($response, 15) );
            break;
        }
    }
    fclose( $fp );
    return $unixtime;
}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.