Time Formatting

In most numbers we write, the largest value comes first. So if I want to write ten plus two hundred, I write 210. Most significant value comes first. If I want to write a time of day, there is a standard format that everybody uses1, so 10:15 means ten hours and fifteen minutes while 15:10 means fifteen hours and ten minutes. Everybody understands it and it is easy to use. If I want to add in seconds, since they are smaller than minutes I put them to the right, so 10:15:20 means 10 hours, fifteen minutes, and twenty seconds.

Now, for some reason, when it comes to dates nobody can agree on ordering. If I say I was born 03-04-05 and my sister was born 06-02-01, which of us is older? Does 01-02-03 come before or after 02-01-03? It depends on where you come from, in the US they tend to list the month and then the day, while Europeans tend to put the day first and then the month. (Correct answer: they are both wrong.) Obviously we can make things clearer by including the four-digit year, which narrows it down since days and months cannot be four digits. The best way to write a date is year-month-day, since that puts the most significant number first. So the date should be written 2020-04-06, that is year 2020, month 04, day 06.

Have you ever been looking at dates sorted alphabetically, such as a list of files where the date is part of the filename? Of course you want things sorted as August, December, February, January, October, ... right? Or would you rather have things sorted first by the day of the month, and then by month? When would that ever be useful? When you use YYYYMMDD, the files get sorted by date automatically. So much easier.

On a slightly related topic, today I found out that Wordpress has a setting to indicate the format of the date that you want, but that setting can be over-ridden each time the date is called using a formatting string. So if you change the date setting, you also have to go to each place the date is used in the theme and check if it is using a formatting string. Because that makes sense, let's have a user settable value that does not actually change anything (/sarc).

Bug report (low priority)/To Do item: On the Wordpress settings page, by the time and date section, there is a link to https://codex.wordpress.org/Formatting_Date_and_Time, this should be updated to https://wordpress.org/support/article/formatting-date-and-time/. The linked help page and the other associated documentation pages should be mirrored/archived in a safe place.

  1. Ignoring for the moment the difference between a 12 hour clock with AM and PM compared to a 24 hour clock []

Tags: , ,

Leave a Reply