# How to get the last updated date of a file using Node.js

> Learn how to get the last modified date of a file in Node.js by calling fs.statSync on the path and reading the mtime Date property it returns.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-10-12 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/how-to-get-last-updated-date-file-node/

All the file functions in [Node.js](https://flaviocopes.com/nodejs/) are provided by the `fs` module. This module exposes a method called `statSync()`, which gets the file details synchronously.

By calling it passing a file path (relative to the file location, or absolute), it will return an object that contains the `mtime` property.

That is a `Date` object instance that contains the file last modified date.

```js
const fs = require('fs')

const getFileUpdatedDate = (path) => {
  const stats = fs.statSync(path)
  return stats.mtime
}
```

Check out the [JavaScript Date guide](https://flaviocopes.com/javascript-dates/) to find out more how to handle the Date object, if you need.
