🌳 Why ISO-8601 is the superior date format

There are many ways to format a date, and they're ambiguous enough that it trips me up every time I see a date in a new system.

Can you tell me which date 01-05-2012 is? Is it the fifth of January 2012 or is it the first of May 2012? It depends on the formatting locale used.

In principle, the date format should respect your locale making for a consistent experience, but in practice this often fails, and the all dates are formatted in either the US format (mm-dd-yyyy) or a reversed version of the ISO-8601 format (dd-mm-yyyy) which for 144 days of the year or for 40% of the year gives ambiguous dates leaving you intrinsically distrusting any date you see.

The only way this could have been worse is if a two number format was common for years. 01-05-12.

What do we do about this? We standardize on, well, the standard, but why is this standard superior to other formats besides being a standard?

Assuming, we stay with mm, dd and yyyy as the building blocks, we have 6 permutations for ordering them. We have

mm-dd-yyyy, mm-yyyy-dd, dd-mm-yyyy
dd-yyyy-mm, yyyy-mm-dd, yyyy-dd-mm

Let's start by seeing why the US format (mm-dd-yyyy) is so so bad. Normally, when you're listing something orderable in a normalized format, you expect that format to be sorted. Date formates have an ordering: a hierarchy of granularity. Years are the least granular, followed by months with dates being the most granular date distinction, so we would not expect the order to be mm-dd-yyyy. This also rules out all the other orderings except for ISO-8601 (yyyy-mm-dd), and reversed ISO-8601 (dd-mm-yyyy) used in most of the world.

comparison of date formats ddmmyyyy mmddyyyy showing the unnatural ordering of month-day-year

Why is the first one better?

First, we notice that with the two formats left, we have resolved the ambiguity. By noting which place the year is located, we can deduce the meaning of the other components, but there is still a reason to prefer one over the other. ISO-8601 has the property that when you have a bunch of ISO-8601 formatted dates, and sort them alphabetically, you also sort them chronologically because the most significant component comes first.

Although you could argue that software should be able to parse the dates, and sort them chronologically, sometimes that is not an option such as when you have dates prefixed in the filenames and want to sort them in common file explorers.

And that's what makes ISO-8601 the superior dateformat with reversed ISO-8601 being an honorable second due to its widespread use.

No matter which date format you choose, I hope we can agree that the traditional US format (mm-dd-yyyy) should never be used to avoid ambiguous dates. The good thing is that in environments where international collaboration is common, the US is increasingly adopting the superior ISO-8601 date format.

Continue reading

Loading...