CTIME(3)                   POSIX Programmer's Manual                  CTIME(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       ctime, ctime_r -- convert a time value to a date and time string

SSYYNNOOPPSSIISS
       #include <time.h>

       char *ctime(const time_t *_c_l_o_c_k);
       char *ctime_r(const time_t *_c_l_o_c_k, char *_b_u_f);

DDEESSCCRRIIPPTTIIOONN
       For _c_t_i_m_e(): The functionality described on this reference page is
       aligned with the ISO C standard. Any conflict between the requirements
       described here and the ISO C standard is unintentional. This volume of
       POSIX.1-2017 defers to the ISO C standard.

       The _c_t_i_m_e() function shall convert the time pointed to by _c_l_o_c_k,
       representing time in seconds since the Epoch, to local time in the form
       of a string. It shall be equivalent to:


           asctime(localtime(clock))

       The _a_s_c_t_i_m_e(), _c_t_i_m_e(), _g_m_t_i_m_e(), and _l_o_c_a_l_t_i_m_e() functions shall
       return values in one of two static objects: a broken-down time
       structure and an array of cchhaarr.  Execution of any of the functions may
       overwrite the information returned in either of these objects by any of
       the other functions.

       The _c_t_i_m_e() function need not be thread-safe.

       The _c_t_i_m_e___r() function shall convert the calendar time pointed to by
       _c_l_o_c_k to local time in exactly the same form as _c_t_i_m_e() and put the
       string into the array pointed to by _b_u_f (which shall be at least 26
       bytes in size) and return _b_u_f.

       Unlike _c_t_i_m_e(), the _c_t_i_m_e___r() function is not required to set _t_z_n_a_m_e.
       If _c_t_i_m_e___r() sets _t_z_n_a_m_e, it shall also set _d_a_y_l_i_g_h_t and _t_i_m_e_z_o_n_e.  If
       _c_t_i_m_e___r() does not set _t_z_n_a_m_e, it shall not set _d_a_y_l_i_g_h_t and shall not
       set _t_i_m_e_z_o_n_e.

RREETTUURRNN VVAALLUUEE
       The _c_t_i_m_e() function shall return the pointer returned by _a_s_c_t_i_m_e()
       with that broken-down time as an argument.

       Upon successful completion, _c_t_i_m_e___r() shall return a pointer to the
       string pointed to by _b_u_f.  When an error is encountered, a null pointer
       shall be returned.

EERRRROORRSS
       No errors are defined.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       These functions are included only for compatibility with older
       implementations. They have undefined behavior if the resulting string
       would be too long, so the use of these functions should be discouraged.
       On implementations that do not detect output string length overflow, it
       is possible to overflow the output buffers in such a way as to cause
       applications to fail, or possible system security violations. Also,
       these functions do not support localized date and time formats. To
       avoid these problems, applications should use _s_t_r_f_t_i_m_e() to generate
       strings from broken-down times.

       Values for the broken-down time structure can be obtained by calling
       _g_m_t_i_m_e() or _l_o_c_a_l_t_i_m_e().

       The _c_t_i_m_e___r() function is thread-safe and shall return values in a
       user-supplied buffer instead of possibly using a static data area that
       may be overwritten by each call.

       Attempts to use _c_t_i_m_e() or _c_t_i_m_e___r() for times before the Epoch or for
       times beyond the year 9999 produce undefined results. Refer to
       _a_s_c_t_i_m_e().

RRAATTIIOONNAALLEE
       The standard developers decided to mark the _c_t_i_m_e() and _c_t_i_m_e___r()
       functions obsolescent even though they are in the ISO C standard due to
       the possibility of buffer overflow. The ISO C standard also provides
       the _s_t_r_f_t_i_m_e() function which can be used to avoid these problems.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       These functions may be removed in a future version.

SSEEEE AALLSSOO
       _a_s_c_t_i_m_e(), _c_l_o_c_k(), _d_i_f_f_t_i_m_e(), _g_m_t_i_m_e(), _l_o_c_a_l_t_i_m_e(), _m_k_t_i_m_e(),
       _s_t_r_f_t_i_m_e(), _s_t_r_p_t_i_m_e(), _t_i_m_e(), _u_t_i_m_e()

       The Base Definitions volume of POSIX.1-2017, <<ttiimmee..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                             CTIME(3)
