TIME(2)

NAME
gettimeofday, time, settimeofday, stime - get / set time

SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
time_t time (time_t *t);
int stime (const time_t *t);
int gettimeofday (struct timeval *tv, struct timezone *tz);
int settimeofday (const struct timeval *tv,
const struct timezone *tz);

DESCRIPTION
time() sets the variable pointed to by t to the time elapsed since the Epoch in seconds, and returns this value.

stime() sets system time to the value pointed to by t, returning 0 on success, and a negative number on failure. stime() may only be executed by the super user.

gettimeofday() and settimeofday() can set the time as well as a timezone. tv is a timeval struct, as specififed in /usr/include/sys/time.h:
struct timeval {
long	tv_sec;		/* seconds */
long	tv_usec;	/* microseconds */
};

and tz is a timezone :
struct timezone {
int	tz_minuteswest;
/* minutes west of Greenwich */
int	tz_dsttime;
/* type of dst correction */
};

With daylight savings times defined as follows :

DST_NONE /* not on dst */
DST_USA /* USA style dst */
DST_AUST /* Australian style dst */
DST_WET /* Western European dst */
DST_MET /* Middle European dst */
DST_EET /* Eastern European dst */
DST_CAN /* Canada */
DST_GB /* Great Britain and Eire */
DST_RUM /* Rumania */
DST_TUR /* Turkey */
DST_AUSTALT /* Australian style with shift in 1986 */

And the following macros are defined to operate on this :
#define FD_SET(fd,fdsetp)	(*(fdsetp) |= (1 << (fd)))
#define FD_CLR(fd,fdsetp)	(*(fdsetp) &= ~(1 << (fd)))
#define FD_ISSET(fd,fdsetp)	((*(fdsetp) >> fd) & 1)
#define FD_ZERO(fdsetp)		(*(fdsetp) = 0)
#define	timerisset(tvp)\
((tvp)->tv_sec || (tvp)->tv_usec)
#define	timercmp(tvp, uvp, cmp)\
((tvp)->tv_sec cmp (uvp)->tv_sec ||\
(tvp)->tv_sec == (uvp)->tv_sec &&\
(tvp)->tv_usec cmp (uvp)->tv_usec)
#define timerclear(tvp)
((tvp)->tv_sec = (tvp)->tv_usec = 0)

Like stime(), only the super user is permitted to use settime(). If either tv or tz is null, then it is not set.

ERRORS
-EPERM is returned if either stime() or settimeofday() is called by someone other than the superuser.

-EINVAL may be returned if an invalid timezone, etc is specified.

FILES
linux/kernel/sys.c
linux/kernel/sched.c
/usr/include/linux/sys.h
/usr/include/unistd.h

BUGS
Linux currently is hazy about GMT and local time. timercmp does not work for >= or <=.