up | Inhaltsverzeichniss | Kommentar

Manual page for gettimeofday(3C)

gettimeofday, settimeofday - get or set the date and time

SYNOPSIS

#include <sys/time.h>

int gettimeofday(struct timeval *tp, void * );

int settimeofday(struct timeval *tp, void * );

MT-LEVEL

MT-Safe

DESCRIPTION

gettimeofday() gets and settimeofday() sets the system's notion of the current time. The current time is expressed in elapsed seconds and microseconds since 00:00 Universal Coordinated Time, January 1, 1970. The resolution of the system clock is hardware dependent; the time may be updated continuously or in clock ticks.

tp points to a timeval structure, which includes the following members:

long    tv_sec;    /* seconds since Jan. 1, 1970 */
long    tv_usec;   /* and microseconds */

If tp is a null pointer, the current time information is not returned or set.

The TZ environment variable holds time zone information. See TIMEZONE.4

The second argument to gettimeofday() and settimeofday() should be a pointer to NULL.

Only the privileged user may set the time of day.

SEE ALSO

adjtime.2 ctime.3c TIMEZONE.4

RETURN VALUES

A -1 return value indicates that an error occurred and errno has been set.

ERRORS

The following error codes may be set in errno:
EINVAL
tp specifies an invalid time.
EPERM
A user other than the privileged user attempted to set the time or time zone.

NOTES

The implementation of settimeofday() ignores the tv_usec field of tp. If the time needs to be set with better than one second accuracy, call settimeofday() for the seconds and then adjtime() for finer accuracy.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 21/April/97