I want to get last modification time of the remote file. I am using this code I found here on stackoverflow
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$url);
//don't fetch the actual page, you only want headers
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_HEADER, true);
//stop it from outputting stuff to stdout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// attempt to retrieve the modification date
curl_setopt($curl, CURLOPT_FILETIME, true);
$result = curl_exec($curl);
echo $result;
$info = curl_getinfo($curl);
print_r($info);
if ($info['filetime'] != -1) { //otherwise unknown
echo date("Y-m-d H:i:s", $info['filetime']); //etc
}
Problem with this code I am getting filetime = -1 all the time. But when I delete
curl_setopt($curl, CURLOPT_NOBODY, true);
then I am getting correct modification time.
Is it possible to get last modification time but with
curl_setopt($curl, CURLOPT_NOBODY, true);
included in the script. I just need header of the page, not body.
Thanks in advance