ftime(3)
π ftime(3) π β return date and time
okay so bestie, this one's a vintage little page from the Library Functions Manual, and it's giving "we don't do this anymore" energy. ngl it's kind of iconic in a haunted-vault way. let's get into it π
β¨ NAME β¨
ftime β return date and time
π LIBRARY π
Standard C library (libc, -lc) π«Ά
πΈ SYNOPSIS πΈ
#include <sys/timeb.h>
[[deprecated]] int ftime(struct timeb *tp);
yes the [[deprecated]] is literally right there in the synopsis π they are not being subtle about it
π DESCRIPTION π
NOTE: This function is no longer provided by the GNU C library. Use clock_gettime(2) instead, bestie. fr fr.
so here's the deal β¨ this function returns the current time as seconds and milliseconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). the time comes back to you in tp, which is declared like this:
struct timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
okay let's break down this struct like it's a group chat π§
timeβ the number of seconds since the Epochmillitmβ the number of milliseconds sincetimeseconds since the Epochtimezoneβ the local timezone, measured in minutes of time west of Greenwich (and a negative value means minutes east of Greenwich, sneaky)dstflagβ a flag that, if nonzero, indicates that Daylight Saving time applies locally during the appropriate part of the year
also, heads up π’ POSIX.1-2001 says that the contents of the timezone and dstflag fields are unspecified β so avoid relying on them, periodt. don't build your whole personality on those two fields.
π«Ά RETURN VALUE π«Ά
this function always returns 0. (POSIX.1-2001 specifies, and some systems document, a -1 error return.) π so like, don't count on the error handling, bestie.
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
- Interface:
ftime() - Attribute: Thread safety
- Value: MT-Safe β¨
so yeah, thread-safe, that's the one slay this function has left π
π STANDARDS π
None. π not a single one. it's giving unclaimed.
π¦ HISTORY π¦
so the lore is: 4.2BSD. then it got marked as LEGACY in POSIX.1-2001, and then removed in POSIX.1-2008. and then removed in glibc 2.33. it's been through the entire character arc and the funeral π
This function is obsolete. Don't use it. like genuinely, bestie, don't.
but if you're stuck and need a replacement π:
- if the time in seconds suffices, time(2) can be used
- gettimeofday(2) gives microseconds
- clock_gettime(2) gives nanoseconds but is not as widely available
so like, pick your fighter based on how much precision you actually need π
π BUGS π
early glibc2 is buggy and returns 0 in the millitm field π but glibc 2.1.1 is correct again. so if your milliseconds are sus, check your glibc version, iykyk.
π SEE ALSO π
and that's the whole page, bestie π this one shipped as part of Linux man-pages 6.20, dated 2025-10-29 β and it lives at ftime(3) in the Library Functions Manual. now go use clock_gettime(2) and never speak of this again π
β¨πΈ
π¦ 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: GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms