GETTIMEOFDAY(3POSIX)
π°οΈ GETTIMEOFDAY(3POSIX) β ok bestie, it's a POSIX Programmer's Manual page π
πΈ PROLOG (read this first, it's giving β¨fine printβ¨)
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 β so if you're on Linux, lowkey go consult the corresponding Linux manual page for the actual tea on Linux behavior β or, plot twist, the interface may not even be implemented on Linux at all. π
π NAME
gettimeofday β get the date and time, periodt.
π SYNOPSIS
#include <sys/time.h>
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
Not me showing you the exact signature so you can't mess it up. Copy it character for character, bestie. π«Ά
π¦ DESCRIPTION
So 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. Unspecified. It's giving mystery, it's giving "don't ask", it's giving we're not telling you the precision. π
And if tzp is not a null pointer? The behavior is unspecified. Not undefined, not defined, justβ¦ unspecified. Nobody knows. Nobody's checking. Keep it NULL and keep it moving. π
β RETURN VALUE
gettimeofday() shall return 0, and β listen carefully β no value shall be reserved to indicate an error. Zero. That's it. That's the whole story. There's no secret error code hiding in the return value, so don't go looking for one. π₯
π ERRORS
No errors are defined.
That's the whole section. Iconic, honestly. Nothing to report.
Heads up though: the following sections are informative. Not normative. Informative. So they're the vibes, not the rules. π§
π EXAMPLES
None. Literally none. We're moving on. π
π APPLICATION USAGE
Real talk: applications should use the clock_gettime() function instead of the gettimeofday() function β because gettimeofday() is obsolescent. That's the technical term for "it's on its way out, bestie, don't get attached." π₯
π RATIONALE
None. Nothing. The rationale is a void. We respect the void. β¨
β οΈ FUTURE DIRECTIONS
The gettimeofday() function may be removed in a future version.
Not a drill. This is the actual warning. If you're building something new on top of it, just know you're building on a bridge that might get demolished. π§
π SEE ALSO
clock_getres()ctime()
Also, from the Base Definitions volume of POSIX.1β2017: <sys_time.h> β note that underscore, iykyk, it's not the header you think it is. π
π COPYRIGHT
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. (Translation: if this page and the official standard disagree, the official standard wins, no cap. π)
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 .
okay that's the whole page bestie, thanks for reading my little lecture about a function you should probably stop using πβ¨ππ¦πΈπ
Signing off with love β this page came from the good people at IEEE/The Open Group, dated 2017, filed under GETTIMEOFDAY(3POSIX). Go forth and call clock_gettime() instead. periodt. π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms