Description | strftime() formats the date and time as specified in the format string and places them in the array pointed to by s. The format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters, including the terminating null byte, are copied unchanged into the array. No more than maxsize bytes are placed in the array. If format is equal to (char *)0 , the default format "%c" will be used.
Each conversion specification is replaced by appropriate characters, as described in the following list. The appropriate characters are determined by the LC_TIME category of the locale and by the contents of timeptr: %%
| The character % | %a
| Abbreviated weekday name of the locale | %A
| Full weekday name of the locale | %b
| Abbreviated month name of the locale | %B
| Full month name of the locale | %c
| Appropriate date and time representation of the locale | %C
| Century (the year divided by 100, truncated to an integer) (00-99) | %d
| Day of the month (01-31) | %D
| Date as %m/%d/%y | %e
| Day of the month (1-31; single digits are preceded by a space) | %f
| Date and time represented in accordance with date() | %F
| Date as %Y-%m-%d | %g
| Year within the century (00-99). Monday is the first day of the week. If the week containing January 1 has four or more days in the new year, then the result is the new year, otherwise the previous year. | %G
| Year in the form ccyy (e.g. 1986). Monday is the first day of the week. If the week containing January 1 has four or more days in the new year, then the result is the new year, otherwise the previous year. | %h
| Abbreviated month name of the locale | %H
| Hours (00-23), 24-hour representation | %I
| Hours (01-12), 12-hour representation | %j
| Day of the year (001-366) | %m
| Number of the month (01-12) | %M
| Minutes (00-59) | %n
| Equivalent to \n | %p
| Locale ́s equivalent of either AM or PM | %r
| Time in the form %I:%M:%S [AMŠPM] | %R
| Time in the form %H:%M | %S
| Seconds (00-61), allows leap seconds | %t
| Inserts a tab character | %T
| Time in the form %H:%M:%S | %u
| Weekday as a number (1-7), Monday = 1 | %U
| Week number of the year (00-53). The first week begins with the first Sunday of the year. All days before the first Sunday of the year belong to week 0. | %V
| Week number of the year (01-53), with Monday as the first day of the week. If the week containing January 1 has four or more days in the new year, then it is considered week 1. Otherwise, it is week 53 of the previous year, and the next week is week 1. | %w
| Weekday as a number (0-6); Sunday = 0 | %W | Week number of the year (01-53), with Monday as the first day of week 1. All days before the first Monday of the year belong to week 0. | %x
| Appropriate date representation of the locale | %X
| Appropriate time representation of the locale | %y
| Year within the century (00-99) | %Y
| Year in the form ccyy (e.g. 1986) | %Z
| Timezone name or its abbreviation | The difference between %U and %W is based on which day is considered the first weekday. Week 01 is the first week in January that begins with a Sunday (for %U ) or a Monday (for %W ). Week number 00 includes the days before the first Sunday (%U ) or Monday (%W ) in January. Modified conversion specifiersSome conversion specifiers can be modified by the characters E or O to indicate that an alternative format or specification should be used rather than the one normally used by the unmodified conversion specifier. If the alternative format or specification does not exist for the current locale, the behavior will be as if the unmodified conversion specification were used. %Ec
| The locale's alternative date and time representation. | %EC
| Name of the base year (period) in the locale's alternative representation. | %Ex
| The locale's alternative date representation. | %EX
| The locale's alternative time representation. | %Ey
| Offset from %EC (year only) in the locale's alternative representation. | %EY
| Alternative representation for the year. | %Od
| Day of the month, using the locale's alternative numeric symbols, padded as needed with leading zeros if an alternative symbol for zero exists; otherwise, with leading spaces. | %Oe
| Day of month, using the locale's alternative numeric symbols, padded as needed with leading spaces. | %OH
| The hour (24-hour clock), using the locale's alternative numeric symbols. | %OI
| The hour (12-hour clock), using the locale's alternative numeric symbols. | %Om
| The month, using the locale's alternative numeric symbols. | %OM
| The minutes, using the locale's alternative numeric symbols. | %OS
| The seconds, using the locale's alternative numeric symbols. | %Ou
| The weekday as a number in the locale's alternative representation (Monday = 1). | %OU
| The week number of the year (Sunday is the first day of the week; rules correspond to %U) using the locale's alternative numeric symbols. | %OV
| The week number of the year (Monday is the first day of the week, rules correspond to %V) using the locale's alternative numeric symbols. | %Ow
| Number of the weekday (Sunday = 0), using the locale's alternative numeric symbols. | %OW | The week number of the year (Monday is the first day of the week), using the locale's alternative numeric symbols. | %Oy
| The year (offset from %C) in the locale's alternative representation, and using the locale's alternative symbols. |
The default language for the output of strftime() is U.S. English. The user can select the output language for strftime() by using setlocale() to set the LC_TIME category for the locale. Local timezone information is set as if strftime() had called the tzset() function. |