2 .\" Copyright 1989 AT&T. Copyright (c) 1980 Regents of the University of California. All rights reserved. The Berkeley software License Agreement specifies the terms and conditions for redistribution. Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
3 .TH GETTIMEOFDAY 3C "Aug 1, 2003"
5 gettimeofday, settimeofday \- get or set the date and time
11 \fBint\fR \fBgettimeofday\fR(\fBstruct timeval *\fR\fItp\fR, \fBvoid *\fR\fItzp\fR);
16 \fBint\fR \fBsettimeofday\fR(\fBstruct timeval *\fR\fItp\fR, \fBvoid *\fR\fItzp\fR);
22 The \fBgettimeofday()\fR function gets and the \fBsettimeofday()\fR function
23 sets the system's notion of the current time. The current time is expressed in
24 elapsed seconds and microseconds since 00:00 Universal Coordinated Time,
25 January 1, 1970. The resolution of the system clock is hardware dependent; the
26 time may be updated continuously or in clock ticks.
29 The \fItp\fR argument points to a \fBtimeval\fR structure, which includes the
34 long tv_sec; /* seconds since Jan. 1, 1970 */
35 long tv_usec; /* and microseconds */
41 If \fItp\fR is a null pointer, the current time information is not returned or
45 The \fBTZ\fR environment variable holds time zone information. See
49 The \fItzp\fR argument to \fBgettimeofday()\fR and \fBsettimeofday()\fR is
53 Only privileged processes can set the time of day.
57 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
58 returned and \fBerrno\fR is set to indicate the error.
62 The \fBsettimeofday()\fR function will fail if:
69 The structure pointed to by \fItp\fR specifies an invalid time.
78 The {\fBPRIV_SYS_TIME\fR} privilege was not asserted in the effective set of
84 The \fBgettimeofday()\fR function will fail for 32-bit interfaces if:
91 The system time has progressed beyond 2038, thus the size of the \fBtv_sec\fR
92 member of the \fBtimeval\fR structure pointed to by \fItp\fR is insufficient to
93 hold the current time in seconds.
99 If the \fBtv_usec\fR member of \fItp\fR is > 500000, \fBsettimeofday()\fR
100 rounds the seconds upward. If the time needs to be set with better than one
101 second accuracy, call \fBsettimeofday()\fR for the seconds and then
102 \fBadjtime\fR(2) for finer accuracy.
106 See \fBattributes\fR(5) for descriptions of the following attributes:
114 ATTRIBUTE TYPE ATTRIBUTE VALUE
116 Interface Stability \fBgettimeofday()\fR is Standard.
124 \fBadjtime\fR(2), \fBctime\fR(3C), \fBgethrtime\fR(3C), \fBTIMEZONE\fR(4),
125 \fBattributes\fR(5), \fBprivileges\fR(5), \fBstandards\fR(5)