// Internet Duct Tape

There is a standard format for date, and it’s name is ISO 8601.

Posted in Programming and Software Development, Technology by engtech on July 27, 2006

Yes Virginia, there is an international standard for date formats, even though the U.S. seems to completely ignore it. It is ISO 8601: YYYY-MM-DD.

But engtech, international standards are for latte sipping foreigners and frenchmen!”

*sips latte and twirls moustache*

Mais oui, mon ami.

But there are other perfectly practical reasons to use it as well. All of your dates can be sorted alphanumerically. Compare the dates 1963-11-22 and 1981-03-30. 19631122 is less than 19810330, and the most basic of sorting algorthims will pick that up. If you are creating filenames that include the date, using ISO-8601 means that the files will be sorted by date if they are sorted in alphabetically order.* The only mechanism needed to accurately compare dates is a string comparison or numerical comparison. That’s it.

Yet people don’t do this. They would rather deal with dates like 07/01/06. Is that July 1st, 2006? January 7th, 2006? There are six reasonable interpretations of that date.

Follow-Up:

* If file creation/access/modification times could be trusted, then you wouldn’t be putting the date in the filename in the first place, would you?

Comments Off

Follow

Get every new post delivered to your Inbox.

Join 286 other followers

%d bloggers like this: