Skip to content
BSD syscall#122

svc · unix #122

settimeofday

Sets the system wall-clock time.

Prototype

int settimeofday(struct timeval *tv, struct timezone *tzp);

Returns: int

Arguments

NameTypeDirDescription
tvstruct timeval-
tzpstruct timezone-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard122
xnu-1486.2.11122
xnu-1504.15.3122
xnu-1504.3.12122
xnu-1504.7.4122
xnu-1504.9.17122
xnu-1504.9.26122
xnu-1504.9.37122

Notes

Requires the effective UID to be root and, under SIP, is restricted further: only entitled processes (timed, systemsetup) can effectively change time. Jumps the clock discontinuously, which is why timed prefers adjtime()/ntp_adjtime() for small skew corrections.

Detection

DTrace syscall::settimeofday:entry exposes the new timeval pointer in arg0. Unified logging from com.apple.timed records every system time change.

Related APIs

gettimeofdayadjtimentp_adjtimentp_gettime