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 Epoch
  • millitm β€” the number of milliseconds since time seconds since the Epoch
  • timezone β€” 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 πŸ’œ:

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