1CTIME(3P)                  POSIX Programmer's Manual                 CTIME(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       ctime, ctime_r — convert a time value to a date and time string
14

SYNOPSIS

16       #include <time.h>
17
18       char *ctime(const time_t *clock);
19       char *ctime_r(const time_t *clock, char *buf);
20

DESCRIPTION

22       For ctime(): The functionality described  on  this  reference  page  is
23       aligned  with the ISO C standard. Any conflict between the requirements
24       described here and the ISO C standard is unintentional. This volume  of
25       POSIX.1‐2008 defers to the ISO C standard.
26
27       The ctime() function shall convert the time pointed to by clock, repre‐
28       senting time in seconds since the Epoch, to local time in the form of a
29       string. It shall be equivalent to:
30
31           asctime(localtime(clock))
32
33       The  asctime(),  ctime(),  gmtime(),  and  localtime()  functions shall
34       return values in one of two static objects: a broken-down  time  struc‐
35       ture and an array of char.  Execution of any of the functions may over‐
36       write the information returned in either of these objects by any of the
37       other functions.
38
39       The ctime() function need not be thread-safe.
40
41       The  ctime_r()  function  shall convert the calendar time pointed to by
42       clock to local time in exactly the same form as  ctime()  and  put  the
43       string  into  the  array  pointed to by buf (which shall be at least 26
44       bytes in size) and return buf.
45
46       Unlike ctime(), the ctime_r() function is not required to  set  tzname.
47       If  ctime_r()  does not set tzname, it shall not set daylight and shall
48       not set timezone.
49

RETURN VALUE

51       The ctime() function shall return the  pointer  returned  by  asctime()
52       with that broken-down time as an argument.
53
54       Upon  successful  completion,  ctime_r()  shall return a pointer to the
55       string pointed to by buf.  When an error is encountered, a null pointer
56       shall be returned.
57

ERRORS

59       No errors are defined.
60
61       The following sections are informative.
62

EXAMPLES

64       None.
65

APPLICATION USAGE

67       These  functions  are included only for compatibility with older imple‐
68       mentations. They have undefined behavior if the resulting string  would
69       be  too  long, so the use of these functions should be discouraged.  On
70       implementations that do not detect output string length overflow, it is
71       possible  to  overflow  the  output  buffers  in such a way as to cause
72       applications to fail, or possible  system  security  violations.  Also,
73       these  functions  do  not  support  localized date and time formats. To
74       avoid these problems, applications should use  strftime()  to  generate
75       strings from broken-down times.
76
77       Values  for  the  broken-down time structure can be obtained by calling
78       gmtime() or localtime().
79
80       The ctime_r() function is thread-safe and  shall  return  values  in  a
81       user-supplied  buffer instead of possibly using a static data area that
82       may be overwritten by each call.
83
84       Attempts to use ctime() or ctime_r() for times before the Epoch or  for
85       times  beyond  the  year  9999 produce undefined results. Refer to asc‐
86       time().
87

RATIONALE

89       The standard developers decided to mark the ctime() and ctime_r() func‐
90       tions obsolescent even though they are in the ISO C standard due to the
91       possibility of buffer overflow. The ISO C standard  also  provides  the
92       strftime() function which can be used to avoid these problems.
93

FUTURE DIRECTIONS

95       These functions may be removed in a future version.
96

SEE ALSO

98       asctime(),  clock(), difftime(), gmtime(), localtime(), mktime(), strf‐
99       time(), strptime(), time(), utime()
100
101       The Base Definitions volume of POSIX.1‐2008, <time.h>
102
104       Portions of this text are reprinted and reproduced in  electronic  form
105       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
106       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
107       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
108       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
109       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
110       event of any discrepancy between this version and the original IEEE and
111       The  Open Group Standard, the original IEEE and The Open Group Standard
112       is the referee document. The original Standard can be  obtained  online
113       at http://www.unix.org/online.html .
114
115       Any  typographical  or  formatting  errors that appear in this page are
116       most likely to have been introduced during the conversion of the source
117       files  to  man page format. To report such errors, see https://www.ker
118       nel.org/doc/man-pages/reporting_bugs.html .
119
120
121
122IEEE/The Open Group                  2013                            CTIME(3P)
Impressum