方法说明:
同步版的 utimes() ,同步方式修改文件时间戳。
语法:
fs.utimesSync(path, atime, mtime)
由于该方法属于fs模块,使用前需要引入fs模块(var fs= require(“fs”) )
接收参数:
path 文件路径
mtime 修改时间 ,表示文件被修改的时间和日期。文件的内容发生改变时,文件的修改日期将随之更新
atime 访问时间 ,表示文件最后被访问的时间和日期。 每一次应用程序或服务使用系统调用,读取一个文件时,文件的访问时间都会更新。
例子:
var fs = require('fs');
fs.utimesSync('125.txt', atime, mtime);
源码:
fs.utimesSync = function(path, atime, mtime) {
nullCheck(path);
atime = toUnixTimestamp(atime);
mtime = toUnixTimestamp(mtime);
binding.utimes(pathModule._makeLong(path), atime, mtime);
};
Statement: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