Get last access time of the current DirectoryIterator item in PHP

Description

The following code shows how to get last access time of the current DirectoryIterator item.

Example


/*www.j  a v a2s  .co  m*/
//Displays a list of the files in the directory 
//of the script and their last access times.
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
foreach ($iterator as $fileinfo) {
    if ($fileinfo->isFile()) {
        echo $fileinfo->getFilename() . " " . $fileinfo->getATime() . "\n";
    }
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip