bug#80974: Add Time conversion specifiers quick reference

Pádraig Brady <[email protected]> Thu, 7 May 2026 18:03:43 +0100
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 07/05/2026 13:25, Pádraig Brady wrote:
> On 07/05/2026 01:46, Dan Jacobson wrote:
>> (info "(coreutils) Time conversion specifiers") is too hard to read
>> through in a hurry.
>>
>> Therefore a second section could be added: "quick reference".
>>
>> And show how we generate it too!:
>>
>> $ for i in {A..Z} {a..z}; do date "+$i: %$i"; done
>> A: Thursday
>> B: May
>> C: 20
>> D: 05/07/26
>> E: %E
>> F: 2026-05-07
>> G: 2026
> Not a bad suggestion.
> Actually we do have many examples in parenthesis,
> so really we could just reformat to:
> 
>        Example   Description
> 
> %%   %         a literal %
> %a   Sun       locale's abbreviated weekday name
> %A   Sunday    locale's full weekday name
> 
> 
> The same could be done in date --help

Testing this locally it looks like the following.
(Also at https://pixelbeat.org/cu/date--help.txt
  in case the following wraps).

cheers,
Padraig


FORMAT  Example    Description

   %%    %           a literal %
   %a    Sun         locale's abbreviated weekday name
   %A    Sunday      locale's full weekday name
   %b    Mar         locale's abbreviated month name
   %B    March       locale's full month name
   %c    '%a %x %X'  locale's date and time
   %C    20          century; like %Y, except omit last two digits
   %d    01          day of month
   %D    12/31/99    date (ambiguous); same as %m/%d/%y
   %e     1          day of month, space padded; same as %_d
   %F    1999-12-31  full date; like %+4Y-%m-%d
   %g    99          year of ISO week number (last two digits; 00-99); see %G
   %G    1999        year of ISO week number; normally useful only with %V
   %h    Mar         same as %b
   %H    23          hour (00..23)
   %I    01          hour (01..12)
   %j    365         day of year (001..366)
   %k     8          hour, space padded ( 0..23); same as %_H
   %l     9          hour, space padded ( 1..12); same as %_I
   %m    12          month (01..12)
   %M    59          minute (00..59)
   %n    \n          a newline
   %N    123456789   nanoseconds (000000000..999999999)
   %p    PM          locale's equivalent of AM or PM; blank if not known
   %P    pm          like %p, but lower case
   %q    4           quarter of year (1..4)
   %r    1:11:04 PM  locale's 12-hour clock time
   %R    23:59       24-hour hour and minute; same as %H:%M
   %s    1778169005  seconds since the Epoch (1970-01-01 00:00 UTC)
   %S    59          second (00..60)
   %t    \t          a tab
   %T    23:59:59    time; same as %H:%M:%S
   %u    7           day of week (1..7); 1 is Monday
   %U    52          week number 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 number of year; Monday as first day of week (00..53)
   %w    6           day of week (0..6); 0 is Sunday
   %x    12/31/99    locale's date (can be ambiguous)
   %X    23:59:59    locale's time representation
   %y    99          year (last two digits; 00..99)
   %Y    1999        year
   %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