Go to the first, previous, next, last section, table of contents.


gettimeofday

Syntax

#include <sys/time.h>

int gettimeofday(struct timeval *tp, struct timezone *tzp);

Description

Gets the current GMT time and the local timezone information. The return structures are as follows:

struct timeval {
  long tv_sec;  /* seconds since 00:00:00 GMT 1/1/1970 */
  long tv_usec; /* microseconds */
};
struct timezone {
  int tz_minuteswest; /* west of GMT */
  int tz_dsttime;     /* set if daylight saving time in affect */
};

If either tp or tzp are NULL, that information is not provided.

Note that although this function returns microseconds for compatibility reasons, the values are precise to less than 1/20 of a second only. The underlying DOS function has 1/20 second granularity, as it is calculated from the 55 ms timer tick count, so you won't get better than that with gettimeofday().

See section settimeofday.

Return Value

Zero on success, nonzero on failure.

Portability

not ANSI, not POSIX


Go to the first, previous, next, last section, table of contents.