GETTIMEOFDAY(3P)

πŸ’– GETTIMEOFDAY πŸ’–

okay bestie, welcome to the POSIX Programmer's Manual page for gettimeofday(3P) β€” yes it's a 3P, that's the POSIX section, iykyk ✨


🫢 PROLOG 🫢

okay so real talk before we get into it: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” like, consult the corresponding Linux manual page for details of Linux behavior β€” or honestly the interface may not be implemented on Linux at all. πŸ’€


✨ NAME ✨

gettimeofday β€” get the date and time πŸ•°οΈ


🌸 SYNOPSIS 🌸

#include <sys/time.h>

int gettimeofday(struct timeval *restrict tp, void *restrict tzp);

πŸ’… DESCRIPTION πŸ’…

The gettimeofday() function shall obtain the current time, expressed as seconds and microseconds since the Epoch, and store it in the timeval structure pointed to by tp. πŸ“…

The resolution of the system clock is unspecified. Yeah bestie, unspecified, don't come for me, that's literally what the standard says. πŸ™ˆ

If tzp is not a null pointer, the behavior is unspecified. Not me passing a non-null tzp and getting undefined behavior… couldn't be me. πŸ‘‘


πŸ”₯ RETURN VALUE πŸ”₯

The gettimeofday() function shall return 0, and no value shall be reserved to indicate an error. That's right, zero is the only energy here. Periodt. ⭐


πŸŽ€ ERRORS πŸŽ€

No errors are defined. ✨

The following sections are informative. (yes queen, informational only, they're giving bonus content)


🌈 EXAMPLES 🌈

None. 😭 Not a single one. The standard said "figure it out bestie."


πŸ¦‹ APPLICATION USAGE πŸ¦‹

Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function. πŸ‘€

fr fr, gettimeofday() is giving legacy. If you're writing new code, clock_gettime() is the main character. Do not ignore this.

πŸ’œ RATIONALE πŸ’œ

None. 🧚


πŸ‘‘ FUTURE DIRECTIONS πŸ‘‘

The gettimeofday() function may be removed in a future version. ⚠️

no cap, it's on the chopping block. Enjoy it while it lasts, bestie.

⭐ SEE ALSO ⭐

  • clock_getres()
  • ctime()
  • The Base Definitions volume of POSIX.1‐2017, <sys_time.h>

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.

In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, babe πŸ’• this edition came from IEEE/The Open Group, dated 2017, and it's the GETTIMEOFDAY(3P) page β€” slay, stay hydrated, and go use clock_gettime() instead. mwah 🫢

πŸ“¦ where this page comes from