size_t strftime(char *s, size_t smax, const char *fmt, const tm *tp);
strftime formats the *tp struct to a null terminated string of maximum size smax-1 into the array at *s based on the fmt format string. The format string consists of conversion specifications and ordinary characters. Conversion specifications start with a % character followed by an optional # character. The following conversion specifications are supported:
| Specification | Description |
| %a | Abbreviated weekday name |
| %A | Full weekday name |
| %b | Abbreviated month name |
| %B | Full month name |
| %c | Date and time representation appropriate for locale |
| %#c | Date and time formatted as "%A, %B %#d, %Y, %H:%M:%S" (Microsoft extension) |
| %C | Century number |
| %d | Day of month as a decimal number [01,31] |
| %#d | Day of month without leading zero [1,31] |
| %D | Date in the form %m/%d/%y (POSIX.1-2008 extension) |
| %e | Day of month [ 1,31], single digit preceded by space |
| %F | Date in the format %Y-%m-%d |
| %h | Abbreviated month name as %b |
| %H | Hour in 24-hour format [00,23] |
| %#H | Hour in 24-hour format without leading zeros [0,23] |
| %I | Hour in 12-hour format [01,12] |
| %#I | Hour in 12-hour format without leading zeros [1,12] |
| %j | Day of year as a decimal number [001,366] |
| %#j | Day of year as a decimal number without leading zeros [1,366] |
| %k | Hour in 24-hour clock format [ 0,23] (POSIX.1-2008 extension) |
| %l | Hour in 12-hour clock format [ 0,12] (POSIX.1-2008 extension) |
| %m | Month as a decimal number [01,12] |
| %#m | Month as a decimal number without leading zeros [1,12] |
| %M | Minute as a decimal number [00,59] |
| %#M | Minute as a decimal number without leading zeros [0,59] |
| %n | Insert newline character (POSIX.1-2008 extension) |
| %p | Locale's a.m or p.m indicator for 12-hour clock |
| %r | Time as %I:%M:%s %p (POSIX.1-2008 extension) |
| %R | Time as %H:%M (POSIX.1-2008 extension) |
| %S | Second as a decimal number [00,59] |
| %t | Insert tab character (POSIX.1-2008 extension) |
| %T | Time as %H:%M:%S |
| %#S | Second as a decimal number without leading zeros [0,59] |
| %U | Week of year as a decimal number [00,53], Sunday is first day of the week |
| %#U | Week of year as a decimal number without leading zeros [0,53], Sunday is first day of the week |
| %w | Weekday as a decimal number [0,6], Sunday is 0 |
| %W | Week number as a decimal number [00,53], Monday is first day of the week |
| %#W | Week number as a decimal number without leading zeros [0,53], Monday is first day of the week |
| %x | Locale's date representation |
| %#x | Locale's long date representation |
| %X | Locale's time representation |
| %y | Year without century, as a decimal number [00,99] |
| %#y | Year without century, as a decimal number without leading zeros [0,99] |
| %Y | Year with century, as decimal number |
| %z,%Z | Timezone name or abbreviation |
| %% | % |