Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

gettimeofday, gettimeofday64 - read current time of day

&pagelevel(4)&pagelevel

Syntax

#include <sys/time.h>

int gettimeofday(struct timeval *tp, void *tzp);
int gettimeofday64(struct timeval64 *tp, void *tzp); 

Description

 gettimeofday() und gettimeofday64() read the current system time, expressed as seconds and microseconds since 00:00 Coordinated Universal Time (UTC), January 1, 1970. The resolution of the system clock is hardware-dependent; the time may be updated continuously or at specific time intervals.

tp points to a structure of type timeval or timeval64, containing the following members:

long tv_sec;           /* seconds since January 1, 1970 */

or

time64_t tv_sec;  /* seconds since January 1, 1970 */

and

long tv_usec;         /* and microseconds */

If tp is a null pointer, the current time is not read.

tzp must be a null pointer, otherwise the behavior is undefined.

Information on time zones is contained in the environment variable TZ. See timezone.

Return val.

0

-1

if successful.

if an error occurs.

Notes

Programs which want to be portable must not rely on the return value -1 in the event of an error.

See also

ctime(), ftime(), timezone, sys/time.h.