This script takes an incoming search string ($query) and checks to see if a file by the same name already appears in the “files” directory. If it exists and is non-empty, the script prints the contents back to the page.
$searchCacheFile = dirname(__FILE__).'/files/'.$query.".txt";
if (file_exists($searchCacheFile) && is_readable($searchCacheFile))
{
$retarr = file_get_contents($searchCacheFile);
if($retarr !=="")
{
print_r($retarr);die;
}
}
I want to add a check to determine the file creation date/time of the $searchCacheFile and compare it to the current date/time to see if more than 48 hours has passed since the file creation.
What method would you use to do the date/time comparison?
Details on the
stat()function here.