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
| Name | Type | Dir | Description |
|---|---|---|---|
| tv | struct timeval | - | |
| tzp | struct timezone | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 122 |
| xnu-1486.2.11 | — | 122 |
| xnu-1504.15.3 | — | 122 |
| xnu-1504.3.12 | — | 122 |
| xnu-1504.7.4 | — | 122 |
| xnu-1504.9.17 | — | 122 |
| xnu-1504.9.26 | — | 122 |
| xnu-1504.9.37 | — | 122 |
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