Get last modification time of current DirectoryIterator item in PHP

Description

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

Example


//from  w  w  w  .j ava2s.  c o m
//Displays a list of the files in the directory of the script and their last modified times.
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
foreach ($iterator as $fileinfo) {
    if ($fileinfo->isFile()) {
        echo $fileinfo->getFilename() . " " . $fileinfo->getMTime() . "\n";
    }
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




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