Is there a basic php method that accepts a URL and retrieves the date last modified from the header?
It would seem like something php can do, but I'm not sure which object to check.
Thanks
Is there a basic php method that accepts a URL and retrieves the date last modified from the header?
It would seem like something php can do, but I'm not sure which object to check.
Thanks
Give this a go.. using cURL.
$c = curl_init('http://...');
curl_setopt($c, CURLOPT_HEADER, 1); // Include the header
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // Return the result instead of printing it
$result = curl_exec($c);
if (curl_errno($c))
die(curl_error($c));
// $result now contains the response, including the headers
if (preg_match('/Last-Modified:(.*?)/i', $result, $matches))
var_dump($matches[1]);
thanks for the code snippet... I tried it but it returns the actual url to the browser and loads it. Although I think with this as as start I may be able to figure out the rest.
thanks again!
Thanks... I tried modifying your version a bit and this seems to work for me:
$c = curl_init('http://...');
curl_setopt($c, CURLOPT_HEADER, 1); // Include the header
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FILETIME, 1);
curl_exec($c);
$result = curl_getinfo($c);
if (curl_errno($c))
die(curl_error($c));
echo date('G:i M jS \'y',(int)$result['filetime']);