Date and Time String Formatting with strftime
Table A-18 shows common date and time string formatting options. Consult your system’s manpages for date and strftime(3), as both the options and what they mean vary from system to system.
Table A-18. strftime format codes
Format | Description |
|---|---|
%% | A literal %. |
| The locale’s abbreviated weekday name (Sun..Sat). |
| The locale’s full weekday name (Sunday..Saturday). |
| The locale’s full month name (January..December). |
| The locale’s abbreviated month name (Jan..Dec). |
| The locale’s default/preferred date and time representation. |
| The century (a year divided by 100 and truncated to an integer) as a decimal number (00..99). |
| The day of the month as a decimal number (01..31). |
| The date in the format |
| The day of month as a blank padded decimal number ( 1..31). |
| The date in the format |
| The two-digit year corresponding to the |
| The four-digit year corresponding to the |
| The hour (24-hour clock) as a decimal number (00..23). |
| The locale’s abbreviated month name (Jan..Dec). |
| The hour (12-hour clock) as a decimal number (01..12). |
| The day of the year as a decimal ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access