The format is defined in a standard, but that standard doesn’t specify en_US
. It’s specified in POSIX, which only cares about the POSIX locale, and states that
When no formatting operand is specified, the output in the POSIX locale shall be equivalent to specifying:
date "+%a %b %e %H:%M:%S %Z %Y"
Historically (e.g. in Unix V7), date
used asctime
, which uses a different format:
Sun Sep 16 01:03:52 1973\n\0
The POSIX format adds the timezone between the time and year.
I don’t know the history of the POSIX-defined format, but I imagine it’s intentionally based on the asctime
-based format.
The history of asctime
can at least be explored, even if the reasoning can’t necessarily be ascertained.
Up to V3, ctime
produced output of the form
Oct 9 17:32:24\0
V4 added the weekday and year, surrounding the format above and producing the format still used by asctime
:
Sun Sep 16 01:03:52 1973\n\0
So it seems the format grew “organically”. At first it included only the month, day in month, and time. When the weekday and year were added, it appears that the existing format was preserved, so the weekday was prepended and the year appended. Finally, when the timezone was added, it was presumably perceived as related to the time rather than the year...
date
"just growed", since the very beginning of Unix. If you're planning on parsingdate
, don't do it. Use thestat
command instead. Readman stat
.date
, and I was wondering how we ended up with such an odd format. Still, at some point, there must have been a decision to put the elements in that funny order.