![]() |
VOOZH | about |
The fsPromises.utimes() method is used to asynchronously change the modification and access timestamps of a file. The timestamps can be specified using a number, string, or Date object. An error would be thrown if the timestamp cannot be converted to a proper number, or is NaN, Infinity or -Infinity.
It changes the file system timestamps of the object referenced by path then resolves the Promise with no arguments upon success.
Syntax:
fsPromises.utimes( path, atime, mtime )
Parameters: This method accepts three parameters as mentioned above and described below:
The atime and mtime arguments follow these rules:
Example: This example to illustrate the fsPromises.utimes() method in Node.js. Create a example_gfg.txt file for input.
Filename: index.js Step to run this program: Run index.js file using the following command:node index.js
Output:
Details before changing time: Modification Time: 2020-06-11T17:25:51.136Z Access Time: 2020-06-11T16:50:51.223Z Details after changing time: Changed Modification Time: 2020-06-11T17:25:51.136Z Changed Access Time: 2020-06-11T16:50:51.223ZReference: https://nodejs.org/api/fs.html#fs_fspromises_utimes_path_atime_mtime