# <sys/time.h> > > > Include the system header <sys/time.h> to define a timeval structure > and the > > > gettimeofday function. > > > struct timeval { > > > time\_t tv\_sec; /\* seconds since Jan. 1, 1970 \*/ suseconds\_t > tv\_usec; /\* and microseconds \*/ > > > }; > > > struct timezone { > > > int tz\_minuteswest; /\* of Greenwich \*/ > > > int tz\_dsttime; /\* type of dst correction to apply > > > }; > > > int gettimeofday(struct timeval \* restrict tp, void \* restrict > tzp); > > > [POSIX] > > > gettimeofday > > > int gettimeofday(struct timeval \* restrict tp, void \* restrict > tzp); > > > [POSIX] Time zone information is no longer provided by this interface. For information on how to retrieve it, see localtime. The system’s notion of the current UTC time is obtained with the gettimeofday call. The time is expressed in seconds and microseconds since midnight (0 hour), January 1, 1970. The resolution of the system clock is hardware dependent, and the time might be updated continuously or in *ticks*. If tp is NULL, the time will not be returned or set. Despite being declared void \*, the objects pointed to by tzp shall be of type struct timezone. > > > The timezone structure is provided only for source compatibility. > gettimeofday will always return zeroes. Last Published: Oct 06, 2026 Previous Topic Next Topic