Skip to content

stat only provide timestamp down to second instead of nanosecond #11946

Open
@kocoten1992

Description

@kocoten1992

Description

Hi maintainer,

stat in php only provide presicion down to second, but it could be down to nanosecond.

  File: abc.xyz
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 8,2	Inode: 6160531     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 0/root)   Gid: ( 0/root)
Access: 2023-08-12 09:10:14.152726478 +0700
Modify: 2023-08-12 09:10:14.152726478 +0700
Change: 2023-08-12 09:10:14.152726478 +0700
 Birth: 2023-08-12 09:10:14.152726478 +0700
[
  ...,
  "atime" => 1691806214,
  "mtime" => 1691806214,
  "ctime" => 1691806214,
  ...
]

I'm aware that https://linux.die.net/man/2/stat does explain it Since kernel 2.5.48, the stat structure supports nanosecond resolution for the three file timestamp fields..

I was running into this problem today, run test need to ensure directory was created within 1s, which cannot be done if read from php stat.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions