stime(2)

๐Ÿ’– stime โ€” set time ๐Ÿ’–

okay bestie, so this page is stime(2), straight out of the System Calls Manual, and it's literally the Unix syscall that sets the whole system's clock. it's giving legacy, and ngl we're gonna talk about why in a sec. โœจ


๐ŸŒธ NAME ๐ŸŒธ

stime โ€” set time ๐Ÿ•ฐ๏ธ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <time.h>

[[deprecated]] int stime(const time_t *t);

๐Ÿฆ‹ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

  • stime():
    • Since glibc 2.19:
      • _DEFAULT_SOURCE
    • glibc 2.19 and earlier:
      • _SVID_SOURCE

like, yes, you literally have to define a macro to even see this function, she's that hidden ๐Ÿ™ˆ


โœจ DESCRIPTION โœจ

NOTE: This function is deprecated; use clock_settime(2) instead.

okay so heads up: stime() is deprecated, bestie. the modern replacement is clock_settime(2) โ€” go hang out with her instead, she's the main character now ๐Ÿ‘‘

stime() sets the system's idea of the time and date. like, the whole system's. every process, every file timestamp, the vibe of the entire machine. the time, pointed to by t, is measured in seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). so t is just a time_t * pointing at a raw epoch-seconds number. simple. iconic.

and the gatekeeping? immaculate. stime() may be executed only by the superuser. if you're not root, she does not know you. ๐Ÿ’…


๐ŸŒˆ RETURN VALUE ๐ŸŒˆ

  • on success, zero is returned ๐Ÿฅณ
  • on error, -1 is returned, and errno is set to indicate the error ๐Ÿ˜ญ

๐Ÿ’œ ERRORS ๐Ÿ’œ

  • EFAULT โ€” Error in getting information from user space. (basically you handed her a pointer she could not read from ๐Ÿ™ˆ)
  • EPERM โ€” The calling process has insufficient privilege. Under Linux, the CAP_SYS_TIME privilege is required. (you tried to touch the clock without the clock-touching pass, bestie ๐Ÿ’€)

โญ STANDARDS โญ

None.

and i oopโ€” she's not in any standard, she's just... there. ungoverned. free-spirited. ๐Ÿงš


๐Ÿ‘‘ HISTORY ๐Ÿ‘‘

  • SVr4.
  • Starting with glibc 2.31, this function is no longer available to newly linked applications and is no longer declared in <time.h>.

so like, if you're compiling something new and you're trying to call her? she's not in the header anymore. she ghosted <time.h> fr fr ๐Ÿ’€ the old binaries still work, but new links get nothing. it's giving retirement arc.


๐Ÿซถ SEE ALSO ๐Ÿซถ


lowkey real talk: if you're reaching for stime() in 2026, please consider clock_settime(2) instead. deprecated is deprecated, no cap. ๐Ÿ”ฅ

this has been your girl walking you through stime(2) from the Linux man-pages 6.20, dated 2026-02-08. stay clocked in, bestie ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms