| Functions | ||||
| Time manipulation | ||||
(C11) | ||||
(C23) | ||||
| Format conversions | ||||
asctimeasctime_s (deprecated in C23)(C11) | ||||
(deprecated in C23)(C11) | ||||
(C95) | ||||
(C23)(C11) | ||||
(C23)(C11) | ||||
| Constants | ||||
| Types | ||||
(C11) |
Defined in header <time.h> | ||
| (1) | ||
char* asctime(conststructtm* time_ptr); | (until C23) | |
[[deprecated]]char* asctime(conststructtm* time_ptr); | (since C23) | |
errno_t asctime_s(char* buf, rsize_t bufsz,conststructtm* time_ptr); | (2) | (since C11) |
Www - three-letter English abbreviated day of the week fromtime_ptr->tm_wday, one ofMon,Tue,Wed,Thu,Fri,Sat,Sun.Mmm - three-letter English abbreviated month name fromtime_ptr->tm_mon, one ofJan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec.dd - 2-digit day of the month fromtimeptr->tm_mday as if printed bysprintf using%2d.hh - 2-digit hour fromtimeptr->tm_hour as if printed bysprintf using%.2d.mm - 2-digit minute fromtimeptr->tm_min as if printed bysprintf using%.2d.ss - 2-digit second fromtimeptr->tm_sec as if printed bysprintf using%.2d.yyyy - 4-digit year fromtimeptr->tm_year+1900 as if printed bysprintf using%4d. This function is deprecated and should not be used in new code. | (since C23) |
asctime_s is 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 constant1 before including<time.h>.Contents |
| time_ptr | - | pointer to atm object specifying the time to print |
| buf | - | pointer to a user-supplied buffer at least 26 bytes in length |
| bufsz | - | size of the user-supplied buffer |
asctime andctime, and may be overwritten on each invocation of any of those functions.asctime returns a pointer to static data and is not thread-safe. POSIX marks this function obsolete and recommendsstrftime instead. The C standard also recommendsstrftime instead ofasctime andasctime_s becausestrftime is more flexible and locale-sensitive.
POSIX limits undefined behaviors only to when the output string would be longer than 25 characters, whentimeptr->tm_wday ortimeptr->tm_mon are not within the expected ranges, or whentimeptr->tm_year exceedsINT_MAX-1990.
Some implementations handletimeptr->tm_mday==0 as meaning the last day of the preceding month.
Possible output:
Tue May 26 21:51:50 2015Tue May 26 21:51:50 2015
(deprecated in C23)(C11) | converts atime_t object to a textual representation (function)[edit] |
| converts atm object to custom textual representation (function)[edit] | |
C++ documentation forasctime | |