Next: ctime_r
, Previous: ctermid
, Up: ISO C and POSIX Function Substitutes [Contents][Index]
ctime
POSIX specification:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html
Gnulib module: ctime
Portability problems fixed by Gnulib:
TZ
has been set by Cygwin.
Portability problems not fixed by Gnulib:
localtime_r
and strftime
(or even sprintf
) instead.
ctime
function need not be reentrant, and consequently is
not required to be thread safe. Implementations of ctime
typically write the timestamp into static buffer. If two threads
call ctime
at roughly the same time, you might end up with the
wrong date in one of the threads, or some undefined string. There is
a reentrant interface ctime_r
.
tzset
.
A more flexible function is strftime
. However, note that it is
locale dependent.