I am trying to get the time stamp of a file on a remote server.
(Date/Time when the file was last uploaded or edited.)
[php]$timestamp = filemtime($url);[/php]
works if on same server (my server) and used to work on other servers with old PHP version.
[php]$timestamp = filemtime($url);[/php]
still works if on same server but not when reading file on some other server.
[php] $filePathName = “http://php.net/manual/en/function.curl-getinfo.php”;
$curl = curl_init($filePathName);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_exec($curl);
if(!curl_errno($curl)){
$timestamp = curl_getinfo($curl, CURLINFO_FILETIME);
// always cleanup.
curl_close($curl);
} else {
$timestamp = strtotime(“1066-01-01, 1:15:30”); // 1/01/1066 = Can’t read file date stamp.
}
print “File date = “.date(“j/m/Y, g:i:sa T”,$timestamp).”
\n”;
[/php]
Dose not work.
I can read the file contents with;
[php] $ch = curl_init($filePathName);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($curl);
curl_close($curl);
[/php]
Is there any other way to get filemtime() with PHP version 7.0.26 ?