I have a PHP on HTTPS page (eg. https://www.example1.com/page1.php) in which I would like to obtain the update date of a second page from a third domain always in HTTPS (eg. https://www.example.com/sitemap.xml).
I tried with the following code, however I always get "was last modified on 01 Jan 1970 01:00:00":
<?php
//The path to the file that you want to get
//the last modified time and date of.
$file = 'https://www.example.com/sitemap.xml';
//Get the last modified time using the filemtime function.
//This function will return a Unix timestamp.
$lastModifiedTimestamp = filemtime($file);
//Convert the timestamp into a human-readable format
//and print it out.
$lastModifiedDatetime = date("d M Y H:i:s", $lastModifiedTimestamp);
echo "$file was last modified on $lastModifiedDatetime";
?>
Could some kind person please help me in finding a solution or alternative?