'\" te .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved. .\" Copyright (c) 1980 Regents of the University of California. All rights reserved. The Berkeley software License Agreement specifies the terms and conditions for redistribution. .TH GETTIMEOFDAY 3UCB "Oct 30, 2007" .SH NAME gettimeofday, settimeofday \- get or set the date and time .SH SYNOPSIS .LP .nf \fB/usr/ucb/cc\fR [ \fIflag\fR ... ] \fIfile\fR ... #include \fBint\fR \fBgettimeofday\fR(\fItp\fR, \fItzp\fR) \fBstruct timeval *\fR\fItzp\fR; \fBstruct timezone *\fR\fItzp\fR; .fi .LP .nf \fBint\fR \fBsettimeofday\fR(\fItp\fR, \fItzp\fR) \fBstruct timeval *\fR\fItzp\fR; \fBstruct timezone *\fR\fItzp\fR; .fi .SH DESCRIPTION .sp .LP The system's notion of the current Greenwich time is obtained with the \fBgettimeofday()\fR call, and set with the \fBsettimeofday()\fR call. The current time is expressed in elapsed seconds and microseconds since 00:00 \fBGMT,\fR January 1, 1970 (zero hour). The resolution of the system clock is hardware dependent; the time may be updated continuously, or in clock ticks. .sp .in +2 .nf long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ .fi .in -2 .sp .LP \fItp\fR points to a \fBtimeval\fR structure, which includes the following members: .sp .LP If \fItp\fR is a \fINULL\fR pointer, the current time information is not returned or set. .sp .LP \fItzp\fR is an obsolete pointer formerly used to get and set timezone information. \fItzp\fR is now ignored. Timezone information is now handled using the \fBTZ\fR environment variable; see \fBTIMEZONE\fR(4). .sp .LP Only the privileged user may set the time of day. .SH RETURN VALUES .sp .LP A \fB\(mi1\fR return value indicates an error occurred; in this case an error code is stored in the global variable \fBerrno\fR. .SH ERRORS .sp .LP The following error codes may be set in \fBerrno\fR: .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n \fItp\fR specifies an invalid time. .RE .sp .ne 2 .na \fB\fBEPERM\fR\fR .ad .RS 10n A user other than the privileged user attempted to set the time. .RE .SH SEE ALSO .sp .LP \fBadjtime\fR(2), \fBctime\fR(3C), \fBgettimeofday\fR(3C), \fBTIMEZONE\fR(4) .SH NOTES .sp .LP Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. .sp .LP \fItzp\fR is ignored in SunOS 5.\fIX\fR releases. .sp .LP \fBtv_usec\fR is always 0.