1GETTIMEOFDAY(2) System Calls Manual GETTIMEOFDAY(2)
2
3
4
6 gettimeofday, settimeofday - get/set date and time
7
9 #include <sys/time.h>
10
11 gettimeofday(tp, tzp)
12 struct timeval *tp;
13 struct timezone *tzp;
14
15 settimeofday(tp, tzp)
16 struct timeval *tp;
17 struct timezone *tzp;
18
20 The system's notion of the current Greenwich time and the current time
21 zone is obtained with the gettimeofday call, and set with the settime‐
22 ofday call. The time is expressed in seconds and microseconds since
23 midnight (0 hour), January 1, 1970. The resolution of the system clock
24 is hardware dependent, and the time may be updated continuously or in
25 ``ticks.'' If tzp is zero, the time zone information will not be
26 returned or set.
27
28 The structures pointed to by tp and tzp are defined in <sys/time.h> as:
29
30 struct timeval {
31 long tv_sec; /* seconds since Jan. 1, 1970 */
32 long tv_usec; /* and microseconds */
33 };
34
35 struct timezone {
36 int tz_minuteswest; /* of Greenwich */
37 int tz_dsttime; /* type of dst correction to apply */
38 };
39
40 The timezone structure indicates the local time zone (measured in min‐
41 utes of time westward from Greenwich), and a flag that, if nonzero,
42 indicates that Daylight Saving time applies locally during the appro‐
43 priate part of the year.
44
45 Only the super-user may set the time of day or time zone.
46
48 A 0 return value indicates that the call succeeded. A -1 return value
49 indicates an error occurred, and in this case an error code is stored
50 into the global variable errno.
51
53 The following error codes may be set in errno:
54
55 [EFAULT] An argument address referenced invalid memory.
56
57 [EPERM] A user other than the super-user attempted to set the
58 time.
59
61 date(1), adjtime(2), ctime(3), timed(8)
62
63
64
654th Berkeley Distribution May 14, 1986 GETTIMEOFDAY(2)