summaryrefslogtreecommitdiff
path: root/usr/src/man/man3ucb/gettimeofday.3ucb
blob: c4d0c6140912852abca394e6c8f2e0ea433245c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'\" 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 <sys/time.h>

\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.