I am using the below code and get the error
Warning: fileatime() [function.fileatime]: Stat failed for abc.txt
(errno=2 - No such file or directory)

$dir='c:\pathname\temp';
$time='1';
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
 echo date("m-d-y H:i:s",fileatime($file));
   if ($file != "." && $file != ".." && fileatime($file) > $time) {
     $time = fileatime($file);
     $lastModifiedFile = $file;
   }
}

closedir($handle);
echo $lastModifiedFile;


-----Original Message-----
From: Jason Barnett [mailto:[EMAIL PROTECTED]
Sent: Monday, April 26, 2004 11:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Re: most latest file


Harpreet wrote:

> Actually I have a backups folder that gets once a day backups of the
> database automaticcaly. I want to be able to know the name fo the the
latest
> file to do the restore. The name of the files have the time stamp and plus
> file has a time last mdified date attached to it.
>
> How can I know which file got restored last using php and also the file
> name.
>
> Thanks

<?php

$directory = 'path/to/backups/directory';

$handle = opendir($directory) {
while (false !== ($file = readdir($handle))) {
   if ($file != "." && $file != ".." && fileatime($file) > $time) {
     $time = fileatime($file);
     $lastModifiedFile = $file;
   }
}

closedir($handle);
echo $lastModifiedFile;

?>

http://www.php.net/readdir
http://www.php.net/manual/en/function.fileatime.php

or, to check file creation times:

http://www.php.net/manual/en/function.filectime.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to