gettimeofday(2) System Calls Manual gettimeofday(2) gettimeofday, settimeofday - / (libc -lc) #include [[]] int gettimeofday(struct timeval *restrict tv, struct timezone *_Nullable restrict tz); [[]] int settimeofday(const struct timeval *tv, const struct timezone *_Nullable tz); glibc ( feature_test_macros(7)): settimeofday(): glibc 2.19: _DEFAULT_SOURCE glibc 2.19 : _BSD_SOURCE gettimeofday() settimeofday() . tv struct timeval ( ): struct timeval { time_t tv_sec; /* */ suseconds_t tv_usec; /* */ }; ( time(2)). tz struct timezone: struct timezone { int tz_minuteswest; /* */ int tz_dsttime; /* */ }; tv tz NULL . ( tv NULL.) timezone tz NULL. . " " settimeofday() ( ) tz NULL tv NULL tz_minuteswest . ( tz_dsttime .) CMOS (UTC). . gettimeofday() settimeofday() 0 . -1 errno . EFAULT tv tz . EINVAL (settimeofday()): timezone . EINVAL (settimeofday()): tv.tv_sec tv.tv_usec [0, 999,999]. EINVAL ( 4.3) (settimeofday()): CLOCK_MONOTONIC ( clock_gettime(2)). EPERM settimeofday() CAP_SYS_TIME. C gettimeofday() vdso(7). NULL tv tz. glibc musl / . bionic / UTC. . 4.3BSD, SVr4. SUSv1 POSIX.1-2001 XSI gettimeofday() settimeofday(). POSIX.1-2008 XSI gettimeofday() clock_gettime(2) . clock_settime(2) settimeofday(). POSIX.1-2024 gettimeofday(). struct timeval long. tz_dsttime glibc tz_dsttime struct timezone gettimeofday() . daylight(3) . glibc tz_dsttime struct timezone settimeofday() gettimeofday(). . tz_dsttime ( ) . (: : .) : DST_NONE /* */ DST_USA /* */ DST_AUST /* */ DST_WET /* */ DST_MET /* */ DST_EET /* */ DST_CAN /* */ DST_GB /* */ DST_RUM /* */ DST_TUR /* */ DST_AUSTALT /* 1986 */ . . gettimeofday() ( ). clock_gettime(2). timeval timeradd(3). date(1), adjtimex(2), clock_gettime(2), time(2), ctime(3), ftime(3), timeradd(3), capabilities(7), time(7), vdso(7), hwclock(8) 3 . . : . 6.18 8 2026 gettimeofday(2)