Skip to content
BSD syscall#116

svc · unix #116

gettimeofday

Returns the current wall-clock time and (legacy) timezone information.

Prototype

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

Returns: int

Arguments

NameTypeDirDescription
tpstruct timeval-
tzpstruct timezone-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard116
xnu-1486.2.11116
xnu-1504.15.3116
xnu-1504.3.12116
xnu-1504.7.4116
xnu-1504.9.17116
xnu-1504.9.26116
xnu-1504.9.37116

Notes

On macOS, the commpage exports a vDSO-style fast path so most calls do not enter the kernel. The second tzp argument is obsolete and should be NULL; timezone data lives in /var/db/timezone. For monotonic timings prefer clock_gettime(CLOCK_MONOTONIC) or mach_absolute_time().

Related APIs

settimeofdayadjtimentp_gettimegetitimersetitimer