统计的时间值


atimeMsmtimeMsctimeMsbirthtimeMs 属性是数值,以毫秒为单位保存相应的时间。 它们的精度是特定于平台的。 当 bigint: true 传给生成对象的方法时,属性将是长整数,否则它们将是数字

atimeNsmtimeNsctimeNsbirthtimeNs 属性是以纳秒为单位保存相应时间的长整数。 它们仅在 bigint: true 传入到生成对象的方法中时出现。 它们的精度是特定于平台的。

atimemtimectimebirthtime 是不同时间的 Date 对象替代表示。 Date 和数字值是不关联的。 分配新的数值或改变 Date 值不会反映在相应的替代表示中。

统计对象中的时间具有以下语义:

  • atime "访问时间": 上次访问文件数据的时间。 由 mknod(2)utimes(2)read(2) 系统调用更改。
  • mtime "修改时间": 上次修改文件数据的时间。 由 mknod(2)utimes(2)write(2) 系统调用更改。
  • ctime "更改时间": 上次更改文件状态(修改索引节点数据)的时间。 由 chmod(2)chown(2)link(2)mknod(2)rename(2)unlink(2)utimes(2)read(2)write(2) 系统调用更改。
  • birthtime "创建时间": 文件创建时间。 创建文件时设置一次。 在出生时间不可用的文件系统上,此字段可能会保存 ctime1970-01-01T00:00Z(即 Unix 纪元时间戳 0)。 在这种情况下,该值可能大于 atimemtime。 在 Darwin 和其他 FreeBSD 变体上,如果使用 utimes(2) 系统调用将 atime 显式设置为比当前 birthtime 更早的值,也会被设置。

在 Node.js 0.12 之前,ctime 是 Windows 系统上的 birthtime。 从 0.12 开始,ctime 不是“创建时间”,在 Unix 系统上,它从来都不是。

The atimeMs, mtimeMs, ctimeMs, birthtimeMs properties are numeric values that hold the corresponding times in milliseconds. Their precision is platform specific. When bigint: true is passed into the method that generates the object, the properties will be bigints, otherwise they will be numbers.

The atimeNs, mtimeNs, ctimeNs, birthtimeNs properties are bigints that hold the corresponding times in nanoseconds. They are only present when bigint: true is passed into the method that generates the object. Their precision is platform specific.

atime, mtime, ctime, and birthtime are Date object alternate representations of the various times. The Date and number values are not connected. Assigning a new number value, or mutating the Date value, will not be reflected in the corresponding alternate representation.

The times in the stat object have the following semantics:

  • atime "Access Time": Time when file data last accessed. Changed by the mknod(2), utimes(2), and read(2) system calls.
  • mtime "Modified Time": Time when file data last modified. Changed by the mknod(2), utimes(2), and write(2) system calls.
  • ctime "Change Time": Time when file status was last changed (inode data modification). Changed by the chmod(2), chown(2), link(2), mknod(2), rename(2), unlink(2), utimes(2), read(2), and write(2) system calls.
  • birthtime "Birth Time": Time of file creation. Set once when the file is created. On file systems where birthtime is not available, this field may instead hold either the ctime or 1970-01-01T00:00Z (ie, Unix epoch timestamp 0). This value may be greater than atime or mtime in this case. On Darwin and other FreeBSD variants, also set if the atime is explicitly set to an earlier value than the current birthtime using the utimes(2) system call.

Prior to Node.js 0.12, the ctime held the birthtime on Windows systems. As of 0.12, ctime is not "creation time", and on Unix systems, it never was.