0
<?php
//basic directory
$dir = 'dir';
//hardcoded hours and minutes for specific time
$hours = 11 ;
$minutes = 2 ;
date_default_timezone_set('Asia/Kolkata');
$today = date('F d, Y');
if (is_dir($dir)) { if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
clearstatcache();
if(is_file($dir."/".$file)) {
//$filename will store the last modified files which in folder
$filename = filemtime($dir."/".$file);
//condition for some relevent time
if(date('F d, Y',$filename) == $today && date("H", $filename) >= $hours && date("i", $filename) >= $minutes)
{
// here i want the sorting code. because it doesnt display the time wise file in output
echo $file;
echo " - ";
echo "Last modified: " . date("F d, Y H:i:s.", $filename);
echo "<br>";
}
}
}
echo "<br>";
closedir($dh);
}
}
?>
/*
i have this output. but it is not perfect i want the last modified come first
through sorting .
test2.php - Last modified: May 26, 2016 11:30:10.
test3.php - Last modified: May 26, 2016 11:32:07.
test.txt - Last modified: May 26, 2016 13:13:11.
*/
'$ filename = filemtime' - あなたの変数名に、内容に完全には関係しない名前を付けることができると思いますか? ;) –