1<?php
2// get current directory path
3$dirpath = getcwd();
4// set file pattern
5$dirpath .= "\*.jpg";
6// copy filenames to array
7$files = array();
8$files = glob($dirpath);
9
10// sort files by last modified date
11usort($files, function($x, $y) {
12 return filemtime($x) < filemtime($y);
13});
14
15foreach($files as $item){
16 echo basename($item) . " => Last Modified On " . @date('F d, Y, H:i:s', filemtime($item)) . "<br/>";
17}
18?>