bug#80974: Add Time conversion specifiers quick reference

Pádraig Brady <[email protected]> Sat, 16 May 2026 12:26:12 +0100
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 09/05/2026 00:50, Bruno Haible via GNU coreutils Bug Reports wrote:
> That's too many lines to search for. As a user, typically I ask:
>    1) I have a day to display; which directive can I use for it?
>    2) I have a time to display; which directive can I use for it?
> 
> Accordingly, I suggest to split this table into several smaller ones,
> namely one for each of:
>    - literal characters,
>    - date
>    - time
>    - date and time
>    - time zone
>    - nanosecond
> (similar to what I did in gnulib/lib/strftime.h).

Sorry I should have confirmed the latest format currently committed,
which is as follows: (Also at https://pixelbeat.org/cu/date--help.txt
in case the following wraps).

cheers,
Padraig

$ src/date --help | sed -n '/^FORMAT  /,/%Z/p'
FORMAT  Example    Description

   %%    %           a literal %
   %n    \n          a newline
   %t    \t          a tab

   %C    20          century; like %Y, except omit last two digits
   %y    99          year (last two digits; 00..99)
   %Y    1999        year
   %g    99          year of ISO week number (last 2 digits; 00-99); see %G
   %G    1999        year of ISO week number; normally useful only with %V

   %a    Sun         locale's abbreviated weekday name
   %A    Sunday      locale's full weekday name
   %b    Mar         locale's abbreviated month name
   %h    Mar         same as %b
   %B    March       locale's full month name
   %m    12          month (01..12)
   %d    31          day of month (01..31)
   %e     1          day of month, space padded; same as %_d
   %D    12/31/99    date (ambiguous); same as %m/%d/%y
   %F    1999-12-31  full date; like %+4Y-%m-%d
   %x    12/31/99    locale's date (can be ambiguous)
   %c    ...         locale's date and time (e.g., Thu Mar  3 23:05 2005)

   %H    23          hour (00..23)
   %I    01          hour (01..12)
   %k     8          hour, space padded ( 0..23); same as %_H
   %l     9          hour, space padded ( 1..12); same as %_I
   %M    59          minute (00..59)
   %S    60          second (00..60)
   %N    123456789   nanoseconds (000000000..999999999)
   %s    1970010100  seconds since the Epoch (1970-01-01 00:00 UTC)
   %p    PM          locale's equivalent of AM or PM; blank if not known
   %P    am          like %p, but lower case
   %r    1:11:04 PM  locale's 12-hour clock time
   %R    23:59       24-hour hour and minute; same as %H:%M
   %T    23:59:59    time; same as %H:%M:%S
   %X    23:59:59    locale's time representation

   %j    365         day of year (001..366)
   %q    4           quarter of year (1..4)
   %u    7           day of week (1..7); 1 is Monday
   %w    6           day of week (0..6); 0 is Sunday
   %U    52          week of year; Sunday as first day of week (00..53)
   %V    52          ISO week number; Monday as first day of week (01..53)
   %W    52          week of year; Monday as first day of week (00..53)

   %z     +0400      +hhmm numeric time zone
   %:z    +04:00     +hh:mm numeric time zone
   %::z   +04:00:00  +hh:mm:ss numeric time zone
   %:::z  +04        numeric time zone to necessary precision; with :
   %Z     EDT        alphabetic time zone abbreviation