To get last modified file date in Node.js, we use the stats.mtime
property.
For instance, we write
fs.stat("/dir/file.txt", (err, stats) => {
const mtime = stats.mtime;
console.log(mtime);
});
to call fs.stat
to get the file metadata for the /dir/file.txt file.
And we use stats.mtime
to get the last modified date.