$files = scandir(__DIR__, SCANDIR_SORT_DESCENDING);
First I tried to check if there is sorting type for the date, but sadly I couldn't find one so I decided to use filemtime
$latest = date("d Y H:i:s.");
printf($latest);
foreach($files as $value) {
if ($value != "..") {
if($value != ".") {
$latestnew = date("d Y", filemtime($value));
if($latestnew > $latest) {
$latest = $value;
}
}
}
}
printf($latest);
You can see that I've a array which many files in it. The latest file name should be in in the $latest variable. I know that the ">" check does not work but I was not able to find another solution. Thanks.