 |
Index for Section 2 |
|
 |
Alphabetical listing for G |
|
gettimeofday(2)
NAME
gettimeofday, settimeofday, ftime - Gets and sets date and time
SYNOPSIS
#include <sys/time.h>
int gettimeofday(
struct timeval *tp,
void *tzp );
#include <sys/timeb.h>
int ftime(
struct timeb *tp );
The following function declarations do not conform to current standards and
are supported only for backward compatibility:
#include <sys/time.h>
int gettimeofday(
struct timeval *tp,
struct timezone *tzp );
int *settimeofday(
struct timeval *tp,
struct timezone *tzp );
LIBRARY
Standard C Library (libc)
STANDARDS
Interfaces documented on this reference page conform to industry standards
as follows:
gettimeofday(), ftime(): XPG4-UNIX
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
PARAMETERS
tp For gettimeofday() and settimeofday(), points to a timeval structure,
defined in the <sys/time.h> file.
For ftime(), points to a timeb structure, defined in the <sys/timeb.h>
file.
tzp [Compaq] For the backward-compatible versions of gettimeofday() and
settimeofday(), points to a timezone structure, defined in the
<sys/time.h> file.
DESCRIPTION
The gettimeofday(), ftime(), and settimeofday() functions get and set the
time and timezone information stored in the kernel.
The gettimeofday() function gets the current time, expressed in seconds and
microseconds since midnight (0 hour), January 1, 1970 UTC (Coordinated
Universal Time, formerly Greenwich Mean Time or GMT), and stores it in the
timeval structure pointed to by tp.
The ftime() function sets the time and millitm members of the timeb
structure pointed to by tp to contain the seconds and milliseconds
portions, respectively, of the current time in seconds since midnight (0
hour), January 1, 1970 UTC.
See the NOTES section for information on the backward-compatible versions
of gettimeofday() and settimeofday().
See the timezone(3) reference page for information on timezone handling on
Tru64 UNIX systems.
NOTES
The following information applies only to the backward-compatible versions
of the gettimeofday() and settimeofday() functions.
[Compaq] The timezone structure that is returned for the gettimeofday()
call is set at boot time by the /sbin/init.d/settime script. The
tz_minuteswest field of the structure is set to your local time zone. This
field is set only for backward compatibility with older applications that
may use the gettimeofday() call for timezone information. The tz_dsttime
field is set to zero because this field is obsolete.
[Compaq] On SVID2-compatible systems, local timezone information is
maintained in the kernel, although the information is not as accurate or as
complete as the information that can be maintained at user level. On these
systems, you can use the tzp parameter with gettimeofday() and
settimeofday() to get and set timezone information in addition to the time.
The tzp parameter returns a pointer to a timezone structure that contains
the local timezone expressed in minutes of time westward from Greenwich and
a flag that, when nonzero, indicates that daylight savings time applies
locally during some part of the year. Note that, if the tzp parameter is
set to NULL, timezone information is not returned or set.
[Compaq] A process must have the sysattr effective privilege to use
settimeofday().
RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. Otherwise, -1
is returned and errno is set to indicate the error.
ERRORS
If the gettimeofday() or settimeofday() function fails, errno may be set
the following value:
[EFAULT]
[Compaq] A parameter points to an invalid address.
[EPERM]
[Compaq] The process's effective user ID does not have the sysattr
effective privilege, which is required for using settimeofday().
SEE ALSO
Commands: date(1), zdump(8), zic(8)
Functions: adjtime(2), ctime(3), getclock(3), gettimer(3), setclock(3),
strftime(3), timezone(3)
Files: tzfile(4)
Standards: standards(5)