Need to read list of files from particular directory with Date modified by descending or ascending in Node js.
I have tried below code but could not get the solution.
fs.readdir(path, function (err, files) {
if (err) throw err;
else {
var res = [];
files.forEach(function (file) {
if (file.split('.')[1] == "json") {
fs.stat(path, function (err, stats) {
});
res.push(file.substring(0, file.length - 5));
}
});
}
stats parameter give mtime as modified time?
Is there any way to get files with modified date.