1

I want to get last modification date of different webpage using php for example last modification date of google , yahoo , or a weblog or ...

I used the code below :

echo "document.write('".date( "F d, Y. H:i:s a", filemtime($filename)));

but it works only for files not webpages ! and for web pages it returns something like this:

Warning: filemtime(): stat failed for http://www.mst.edu/ in C:\xampp\htdocs\Final\api.php on line 56

document.write('January 01, 1970. 01:00:00 am');
chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256
Armita
  • 21
  • 1
  • 6
  • Check this out... http://stackoverflow.com/questions/845220/get-the-last-modified-date-of-a-remote-file – MTH Sep 15 '13 at 23:05

1 Answers1

1

The manual for filemtime states:

As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to Supported Protocols and Wrappers to determine which wrappers support stat() family of functionality.

It also states for the http:// wrapper that it does not support stat().

So you can't use filemtime to get what you want. However, sites may expose their last modified time in the Last-Modified HTTP response header. For this, you could use the built-in get_headers:

$headers = get_headers('http://www.mst.edu/');
var_dump($headers['Last-Modified']);

Or you could use cURL, as in this answer.

Community
  • 1
  • 1
cmbuckley
  • 40,217
  • 9
  • 77
  • 91