1CTIME(3P) POSIX Programmer's Manual CTIME(3P)
2
3
4
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
12 ctime, ctime_r - convert a time value to a date and time string
13
15 #include <time.h>
16
17 char *ctime(const time_t *clock);
18
19
20 char *ctime_r(const time_t *clock, char *buf);
21
22
24 For ctime(): The functionality described on this reference page is
25 aligned with the ISO C standard. Any conflict between the requirements
26 described here and the ISO C standard is unintentional. This volume of
27 IEEE Std 1003.1-2001 defers to the ISO C standard.
28
29 The ctime() function shall convert the time pointed to by clock, repre‐
30 senting time in seconds since the Epoch, to local time in the form of a
31 string. It shall be equivalent to:
32
33
34 asctime(localtime(clock))
35
36 The asctime(), ctime(), gmtime(), and localtime() functions shall
37 return values in one of two static objects: a broken-down time struc‐
38 ture and an array of char. Execution of any of the functions may over‐
39 write the information returned in either of these objects by any of the
40 other functions.
41
42 The ctime() function need not be reentrant. A function that is not
43 required to be reentrant is not required to be thread-safe.
44
45 The ctime_r() function shall convert the calendar time pointed to by
46 clock to local time in exactly the same form as ctime() and put the
47 string into the array pointed to by buf (which shall be at least 26
48 bytes in size) and return buf.
49
50 Unlike ctime(), the thread-safe version ctime_r() is not required to
51 set tzname.
52
54 The ctime() function shall return the pointer returned by asctime()
55 with that broken-down time as an argument.
56
57 Upon successful completion, ctime_r() shall return a pointer to the
58 string pointed to by buf. When an error is encountered, a null pointer
59 shall be returned.
60
62 No errors are defined.
63
64 The following sections are informative.
65
67 None.
68
70 Values for the broken-down time structure can be obtained by calling
71 gmtime() or localtime(). The ctime() function is included for compati‐
72 bility with older implementations, and does not support localized date
73 and time formats. Applications should use the strftime() function to
74 achieve maximum portability.
75
76 The ctime_r() function is thread-safe and shall return values in a
77 user-supplied buffer instead of possibly using a static data area that
78 may be overwritten by each call.
79
81 None.
82
84 None.
85
87 asctime(), clock(), difftime(), gmtime(), localtime(), mktime(), strf‐
88 time(), strptime(), time(), utime(), the Base Definitions volume of
89 IEEE Std 1003.1-2001, <time.h>
90
92 Portions of this text are reprinted and reproduced in electronic form
93 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
94 -- Portable Operating System Interface (POSIX), The Open Group Base
95 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
96 Electrical and Electronics Engineers, Inc and The Open Group. In the
97 event of any discrepancy between this version and the original IEEE and
98 The Open Group Standard, the original IEEE and The Open Group Standard
99 is the referee document. The original Standard can be obtained online
100 at http://www.opengroup.org/unix/online.html .
101
102
103
104IEEE/The Open Group 2003 CTIME(3P)