Home > Web Front-end > JS Tutorial > Instructions for using the fs.utimes method in node.js_node.js

Instructions for using the fs.utimes method in node.js_node.js

WBOY
Release: 2016-05-16 16:27:06
Original
1402 people have browsed it

Method description:

Modify file timestamp asynchronously.

Grammar:

Copy code The code is as follows:

fs.utimes(path, atime, mtime, callback)

Since this method belongs to the fs module, the fs module needs to be introduced 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 modification date of the file will be updated

atime access time, indicating the time and date when the file was last accessed. Every time an application or service uses a system call to read a file, the file's access time is updated.

callback Callback, passing an exception parameter err

Example:

Copy code The code is as follows:

var fs = require('fs');
fs.utimes('125.txt', atime, mtime, function(err){
if(err){
throw err;
}
console.log('time update');
})

Source code:

Copy code The code is as follows:

fs.utimes = function(path, atime, mtime, callback) {
callback = makeCallback(callback);
if (!nullCheck(path, callback)) return;
binding.utimes(pathModule._makeLong(path),
                     toUnixTimestamp(atime),
                    toUnixTimestamp(mtime),
                  callback);
};
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template