Method description:
The synchronous version of utimes() is used to modify the file timestamp.
grammar:
The code copy is as follows:
fs.utimesSync(path, atime, mtime)
Since this method belongs to the FS module, it is necessary to introduce the FS module before use (var fs= require("fs") )
Receive parameters:
path file path
mtime Modification time, indicating the time and date when the file was modified. When the content of the file changes, the file modification date will be updated accordingly.
atime access time, indicating the time and date when the file was last accessed. Every time an application or service uses a system call, the access time of the file will be updated when a file is read.
example:
The code copy is as follows:
var fs = require('fs');
fs.utimesSync('125.txt', atime, mtime);
Source code:
The code copy is as follows:
fs.utimesSync = function(path, atime, mtime) {
nullCheck(path);
atime = toUnixTimestamp(atime);
mtime = toUnixTimestamp(mtime);
binding.utimes(pathModule._makeLong(path), atime, mtime);
};