[buug] ISO date format

Michael Paoli Michael.Paoli at cal.berkeley.edu
Thu Jan 17 18:16:19 PST 2013

At the last (2012-01-03) BUUG meeting, among other things discussed,
date and date/time format came up.  I mentioned ISO[1] date format,
and that I'd been using ISO date format, particularly the form:
YYYY-MM-DD since sometime in 1998.  Among some of its key advantages:
Y2K compliant
sorts quite logically and simply,
language independent,
well known to more people on the planet than any other format.

Both basic and extended format were discussed, but not by name.  I note
that apparently the standard states: "The basic format should be avoided
in plain text." - essentially, the extended format is the preferred
format for human readability.

ISO date format is also conveniently available via date(1),
e.g., on POSIX/SUS[2] compliant systems:
$ date +%Y-%m-%d
or additionally, on systems with GNU date[3]:
$ date -I

Full time, to precision of second (or sometimes more) is also available,
$ date +%Y-%m-%dT%H:%M:%S
$ date -Iseconds

Note however that POSIX/SUS doesn't include convenient means to provide
timezone information in proper ISO format, however it can be fairly
easily coerced to do so, e.g.:
$ TZ=GMT0 date +%Y-%m-%dT%H:%M:%S+00:00
$ TZ=PST8 date +%Y-%m-%dT%H:%M:%S-0800

Anyway, the simple sorting bit works great with just the dates, and in
a consistent ISO format.  When also including the time, it then becomes
a matter of timezone(s), consistent use and formatting thereof, and
Daylight Saving Time / Summer Time vs. not.  In all cases if one always
uses GMT0 (UTC, Z), and same precision and formatting, sorting
chronologically works quite simply and reliably.

Note also, that when it comes to logs and security, some entities won't
even accept or review/consider logs unless they're in UTC (GMT0).  Not
only does GMT0 (UTC) make so much sense for hardware clocks (and has
been what Unix, at least historically, uses for hardware clocks), but
in many cases - e.g. data/usage across timezones, or systems that
travel across timezones, it often makes for a sensible, or even "best"
choice, for system default timezone or system "local" time - though it
often may not make best or most convenient default timezone for "users"
- though that can, of course, be changed on user-by-user basis, or even
a different default created for "regular users".

Note also that many UNIX/Linux utilities and logging, etc., are (slowly)
tending more and more towards ISO date format in many cases.

And yes, I've at least occasionally made earlier mention[4] of ISO date

1. http://en.wikipedia.org/wiki/ISO_8601
2. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html

More information about the buug mailing list