c timespec

#include <stdio.h>
#include <time.h>

int main() {
    struct timespec ts;

    // Get the current time
    clock_gettime(CLOCK_REALTIME, &ts);

    // Access seconds and nanoseconds components
    time_t seconds = ts.tv_sec;
    long nanoseconds = ts.tv_nsec;

    // Print the obtained values
    printf("Seconds: %ld\n", seconds);
    printf("Nanoseconds: %ld\n", nanoseconds);

    return 0;
}