gettimeofday
Purpose
Obtains current time.
Library
Berkeley Library (libbsd.a)
Syntax
#include <bsd/sys/time.h>
int gettimeofday (tp, tzp)
struct timeval *tp;
struct timezone *tzp;
Description
The gettimeofday subroutine gets the current Greenwich
time and the current time zone. The time is expressed in
seconds and microseconds. If tzp equals 0, the system
omits the time zone.
The tp parameter points to a timeval structure, defined
in the file bsd/sys/time.h. This structure contains the
following members:
long tv_sec; /* Seconds since Jan. 1, 1970 */
long tv_usec; /* Microseconds to add to seconds */
The tzp parameter points to a timezone structure, defined
in the bsd/sys/time.h file. This structure contains the
following members:
int tz_minuteswest; /* Time west of Greenwich in minutes */
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),
and a flag that, if nonzero, indicates that daylight
saving time applies locally during the appropriate part
of the year.
To set the current time, use the time system call or the
date command.
Return Value
If the call succeeds, a value of 0 is returned. If an
error occurs, a value of -1 is returned, and an error
code is placed in the global variable errno.
Diagnostics
If an argument address points to an invalid segment of
memory, the system issues a SIGSEGV. If the process does
not respond, it is terminated with a core dump.
Related Information
In this book: "ctime, localtime, gmtime, asctime, tzset"
and "time."
The date command in AIX Operating System Commands Refer-
ence.
The discussion of timed in Interface Program for use with
TCP/IP.