ctime, ctime_r, ctime_s
Defined in header
char* ctime ( const time_t* timer );
char* ctime_r( const time_t* timer, char* buf );
errno_t ctime_s( char *buf, rsize_t bufsz, const time_t* timer );
timeris a null pointer
bufszis less than 26 or greater than RSIZE_MAX
- As with all bounds-checked functions,
ctime_sis only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including
The resulting string has the following format:
Www Mmm dd hh:mm:ss yyyy\n
Www- the day of the week (one of
Mmm- the month (one of
dd- the day of the month
The function does not support localization.
|timer||-||pointer to a time_t object specifying the time to print|
|buf||-|| pointer to the first element of a char array of size at least |
|bufsz||-|| max number of bytes to output, typically the size of the buffer pointed to by |
 Return value
ctime, and may be overwritten on each invocation of any of those functions.
buf, which points to a null-terminated character string holding the textual representation of date and time as described above after returning.
buf), or non-zero on failure (in which case, the terminating null character is always written to buf unless
bufis a null pointer or
bufszis zero or greater than RSIZE_MAX.
ctime returns a pointer to static data and is not thread-safe. In addition, it modifies the static tm object which may be shared with gmtime and localtime. POSIX marks this function obsolete and recommends strftime instead. The C standard also recommends strftime instead of
strftime is more flexible and locale-sensitive.
The behavior of
ctime_r is undefined for the values of time_t that result in the string longer than 25 characters (e.g. year 10000).
Tue May 26 21:51:03 2015 Tue May 26 21:51:03 2015
- C11 standard (ISO/IEC 9899:2011):
- 188.8.131.52 The ctime function (p: 393)
- K.184.108.40.206 The ctime_s function (p: 626)
- C99 standard (ISO/IEC 9899:1999):
- 220.127.116.11 The ctime function (p: 342)
- C89/C90 standard (ISO/IEC 9899:1990):
- 18.104.22.168 The ctime function
 See also
| converts a |
| converts a |
C++ documentation for ctime