GETTIMEOFDAY(2)
NAME
gettimeofday, settimeofday − get/set date and time
USAGE
#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 idea of the current Greenwich time and the current time zone. Time returned is expressed 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 { u_long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; struct timezone { inttz_minuteswest;/* of Greenwich */ inttz_dsttime;/* type of dst correction to apply */ }; The timezone structure indicates the local time zone (measured in minutes of time westward from Greenwich), and a flag that, if nonzero, indicates that Daylight Saving time applies locally during the appropriate part of the year.
Settimeofday is illegal on DOMAIN/IX systems. Any attempt to set the time returns an error.
NOTES
Time is not correct to the microsecond values.
RETURN VALUE
A successful call returns zero. A failed call returns -1 and sets errno as indicated below.
ERRORS
The following error codes may be set in errno:
[EFAULT] An argument address referred to invalid memory.
[EPERM] On DOMAIN/IX Systems, an attempt was made to use settimeofday. On other systems, an unprivileged process attempted use settimeofday.