MacOS is POSIX compliant, and is certified as such. Therefore you can also check the POSIX documentation for date
. Here it does list the available format specifiers:
Conversion Specifications
%a
Locale's abbreviated weekday name.
%A
Locale's full weekday name.
%b
Locale's abbreviated month name.
%B
Locale's full month name.
...
It's a shame that the Mac's man page omits this useful information directly. However, it does contain this paragraph:
An operand with a leading plus (+
) sign signals a user-defined format string which specifies the format in which to display the date and time. The format string may contain any of the conversion specifications described in the strftime(3) manual page, as well as any arbitrary text. A newline (\n
) character is always output after the characters specified by the format string.
In the SEE ALSO section there is also a reference to strftime(3).
Unfortunately, on my Mac at least, there is no strftime(3) man page, so it's not possible to get to further information without referencing documentation online. (Apparently the C library man pages are installed as part of XCode.)
date
program. It's FOSS, after all.date
command accept at least one more format specifier thanstrftime
does, namely%s
, to print a rawtime_t
value (seconds since 1970)..strftime
, at least on macOS, is documented as accepting%s
.