The
stats.ctime property is an inbuilt application programming interface of the fs.Stats class that is used to get the timestamp when the file status has been changed last time.
Syntax:
stats.ctime
Return Value: It returns a date value that represents the timestamp when the file status has been changed last time.
Below examples illustrate the use of stats.ctime property in Node.js:
Example 1:
Output:
Using stat: Sun Jun 21 2020 01:17:13 GMT+0530 (India Standard Time)
Using lstat: Sun Jun 21 2020 01:19:02 GMT+0530 (India Standard Time)
Example 2:
Output:
(node:2748) ExperimentalWarning: The fs.promises API is experimental
Using stat synchronous: Sun Jun 21 2020 01:19:02 GMT+0530
(India Standard Time)
Note: The above program will compile and run by using the
node filename.js command and use the file_path correctly.
Reference: https://nodejs.org/api/fs.html#fs_stats_ctime