Does the function clock_gettime
return a timestamp measured from the epoch in UTC or in the local time zone?
I know that time
is supposed to be from the UTC epoch, but I can't find any reference saying the same is true of clock_gettime
.
CLOCK_MONOTONIC A nonsettable system-wide clock that represents monotonic time since—as described by POSIX—"some unspecified point in the past". On Linux, that point corresponds to the number of seconds that the system has been running since it was booted.
The clock_gettime function is found in the runtime library. To include this in the link add the library to the cc command by appending -lrt to the list of libraries.
To quote Wikipedia, the Unix Epoch is defined as
the time 00:00:00 UTC on 1 January 1970 (or 1970-01-01T00:00:00Z ISO 8601).
From this it follows that any reference to "the Epoch" implies UTC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With