DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

gettimeofday(S)


gettimeofday, settimeofday -- get or set the date and time

Syntax

cc . . . -lc
#include <sys/time.h>

int gettimeofday(struct timeval *tp);

int settimeofday(struct timeval *tp);

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 1970-01-01 00:00 UTC. The behavior of the system clock is determined by space.c parameters discussed on the clock(HW) manual page.

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.

Only the privileged user may set the time of day.

Return values

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

Diagnostics

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.

Files


/lib/libc.a
linking library

See also

adjtime(S), ctime(S), timezone(S)

Standards conformance

gettimeofday and settimeofday are conformant with:

AT&T SVID Issue 3.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003