find the last modified date of a json file in typescript

Here's an example code snippet in TypeScript using Node.js' fs (filesystem) module to get the last modified date of a JSON file:

index.ts
import * as fs from 'fs';

const filename = 'data.json';

fs.stat(filename, (err, stats) => {
  if(err) {
    console.error(`Error getting file stats: ${err}`);
    return;
  }

  const lastModified = stats.mtime;
  console.log(`Last modified date: ${lastModified}`);
});
272 chars
14 lines

In this code snippet, we're importing Node.js' built-in fs module and defining a filename variable containing the name of our JSON file. We then use the fs.stat() function to get the file stats, including the mtime (last modified time) property. Finally, we log the last modified date to the console.

gistlibby LogSnag