Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is clock_gettime a UTC time, or local time zone?

Tags:

linux

posix

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.

like image 459
edA-qa mort-ora-y Avatar asked Dec 16 '11 09:12

edA-qa mort-ora-y


People also ask

What is Clock_monotonic?

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.

What library is Clock_gettime in?

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.


1 Answers

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.

like image 89
NPE Avatar answered Oct 11 '22 12:10

NPE