You can use the fs.stat() method provided by the built-in fs module in Node.js to get the file statistics, including the last accessed timestamp. Here's an example:
146 chars8 lines
In the above code, replace path/to/file with the actual file path. The fs.stat() method takes a callback function that receives an error object (if any) and a stats object.
The stats object contains various file statistics, including the last accessed timestamp, which is returned by the stats.atime property.
You can format the timestamp using the Date() constructor, like this:
56 chars2 linesThis will output the timestamp in a human-readable format.
gistlibby LogSnag