Name
strftime function — Formats a time as a string
Synopsis
size_t strftime(char* str, size_t n, const char* fmt, const tm* tmptr)
The strftime
function
formats a tm
object as a string.
Up to n
bytes are stored in
str
, including a terminating null
character. The return value is the number of characters actually
stored, not counting the final null character. If the formatted
result requires more than n
characters, the return value is 0
.
Characters from fmt
are
copied to str
, except conversion
specifiers, which start with a percent sign (%
) and are followed by one of the letters
shown in Table 13-6.
The LC_TIME
category in the
current C locale controls the text that is copied to str
for each conversion specifier.
Specifier | Description |
| Abbreviated weekday name |
| Full weekday name |
| Abbreviated month name |
| Full month name |
| Complete date and time |
| Day of the month ( |
| Hour ( |
| Hour ( |
| Day of the year ( |
| Month ( |
| Minutes ( |
| A.M./P.M. designation for use with a 12-hour clock |
| Second ( |
| Week number ( |
| Weekday ( |
| Week number ( |
| Date |
| Time |
| Year in century ( |
| Year |
| Time zone name or abbreviation, or empty string if time zone is unknown |
| Literal |
See Also
asctime function, ctime function, tm struct, time_put
in <locale>
, <clocale> ...
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.