Are there any commands showing Apple File System (APFS) timestamps in nanoseconds?
Asked Answered
D

2

8

I heard that timestamps in APFS are in nanoseconds.

Are there any commands that are able to show APFS timestamps in nanoseconds?

I've tried ls, stat but no luck so far.

Domesticity answered 9/10, 2017 at 5:21 Comment(2)
are you try this: echo $(($(date +%s%N)/1000000)) just run this command in your terminalMegalocardia
@YaseenAhmad Running your command results in this error: bash: 1508845153N: value too great for base (error token is "1508845153N"). What I want to know is not current time but timestamps of files.Domesticity
A
5

You can get nanosecond timestamps by requesting floating point output:

% stat -f %Fm foo
1609297230.485880489
Adebayo answered 30/12, 2020 at 4:10 Comment(0)
C
-1

There are no commands, but you can create a simple C program to test it:

#include <stdio.h>
#include <sys/stat.h>

int main() {
    struct stat attr;
    stat("/path/to/file", &attr);
    printf("Last modified time: %ld", (long)attr.st_mtimespec.tv_nsec);
}
Computerize answered 21/8, 2018 at 6:46 Comment(1)
That should likely read (long)attr.st_mtimespec.tv_nsec - no point in printing the address of the value...Cammiecammy

© 2022 - 2024 — McMap. All rights reserved.