gettimeofday(2) System Calls Manual gettimeofday(2) gettimeofday, settimeofday - / LIBRARY Standard C library (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() , . The tv argument is a struct timeval (as specified in ): struct timeval { time_t tv_sec; /* */ suseconds_t tv_usec; /* */ }; , (. time(2)). tz struct timezone: struct timezone { int tz_minuteswest; /* */ int tz_dsttime; /* DST */ }; tv tz NULL, ( , tv NULL). timezone ; tz NULL (. ). Linux << >> (warp clock), settimeofday(), ( ), tz NULL, tv NULL tz_minuteswest ( tz_dsttime ). , (CMOS clock) , UTC. , , . gettimeofday() and settimeofday() return 0 for success. On error, -1 is returned and errno is set to indicate the error. EFAULT tv tz . EINVAL (settimeofday()): timezone. EINVAL (settimeofday()): tv.tv_sec is negative or tv.tv_usec is outside the range [0, 999,999]. EINVAL ( Linux 4.3) (settimeofday()): CLOCK_MONOTONIC ( clock_gettime(2)). EPERM settimeofday(); Linux CAP_SYS_TIME. C gettimeofday() vdso(7). The kernel accepts NULL for both tv and tz. The timezone argument is ignored by glibc and musl, and not passed to/from the kernel. Android's bionic passes the timezone argument to/from the kernel, but Android does not update the kernel timezone based on the device timezone in Settings, so the kernel's timezone is typically UTC. gettimeofday() POSIX.1-2008 (obsolete). settimeofday() None. SVr4, 4.3BSD. POSIX.1-2001 gettimeofday(), settimeofday(). POSIX.1-2008 gettimeofday() , clock_gettime(2). , struct timeval long. tz_dsttime Linux, glibc, tz_dsttime struct timezone gettimeofday() , . daylight(3) . Linux glibc tz_dsttime struct timezone settimeofday() gettimeofday(). , . tz_dsttime ( ), (Daylight Saving Time) (: ). : DST_NONE /* DST */ DST_USA /* DST */ DST_AUST /* DST */ DST_WET /* DST */ DST_MET /* DST */ DST_EET /* DST */ 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) Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . gettimeofday(2)