GETTIMEOFDAY(2) COMMAND REFERENCE GETTIMEOFDAY(2)
NAME
gettimeofday, settimeofday - get/set date and time
SYNOPSIS
#include <sys/time.h>
gettimeofday(tp, tzp)
struct timeval *tp;
struct timezone *tzp;
settimeofday(tp, tzp)
struct timeval *tp;
struct timezone *tzp;
DESCRIPTION
gettimeofday returns the system's current Greenwich time and
time zone in the structures pointed to by tp and tzp.
settimeofday sets the time using the contents of the
structures. Only the superuser can set the time.
Refer to date(1) for more details.
Time returned is expressed relative in seconds and
microseconds since midnight January 1, 1970.
The structures pointed to by tp and tzp are defined in
<sys/time.h> as:
struct timeval {
long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
};
The timezone structure indicates the local time zone
measured in minutes of time westward from Greenwich. The
flag tz_dsttime, if nonzero, indicates that Daylight Saving
time applies locally during the appropriate part of the
year.
DIAGNOSTICS
If gettimeofday and settimeofday fail, they can set the
following error in errno:
[EFAULT] An argument address references invalid memory.
In addition, settimeofday can set the following error:
Printed 4/6/89 1
GETTIMEOFDAY(2) COMMAND REFERENCE GETTIMEOFDAY(2)
[EPERM] The caller is not the super-user.
RETURN VALUE
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
CAVEATS
Time is never correct enough to believe the microsecond
values. There should be a mechanism by which, at least,
local clusters of systems might synchronize their clocks to
millisecond granularity.
If tp is NULL, the time system time will not be returned or
set. If tzp is NULL, the time zone information will not be
returned or set.
SEE ALSO
date(1) and ctime(3c).
Printed 4/6/89 2
%%index%%
na:432,102;
sy:534,1597;
de:2131,1507;
di:3638,711;4853,52;
rv:4905,280;
ca:5185,460;
se:5645,164;
%%index%%000000000132