[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


Date formats are for humans. Machines just use the type.

Published on
8,064 Points
Last Modified:
One of the most frequent problems a "newbie" developer may encounter is having to deal with different data formats. One for all: THE DATE

We, as humans, need to "see" a date and then interpret it (much of the times this is an automatic operation).

What if I show you: "07/05/2013"?
Many of you would certainly recognize it as July 5, 2013.
For just as many (like me), the same format would mean May 7, 2013...

The problem arises from the fact that the format in which this date is shown (and recognized) varies according to the origin and culture.

Human thinking is really far from my field of study, but for sure different contexts lead to different solutions.

Since (until proven otherwise) machines do not think, we should not expect that machines too have our same problems.
We should limit our programs to only "show" a certain type of data (in this case a Date) in the format expected by the user (because the user is human and prefers a format applied to the type). We should have in mind that date formats are solely for our own interpretation.

Machines don't really need "a format", they understand dates (times) as a number stored in a date/time column.

Since we could consider formatting for "show" only, then this is an exclusive operation of the user interfaces.

Everything else, that does not concern the user, MUST NOT have to deal with the formatting of dates.

So we can say that:

A well designed application should not give any "issue date" to any programmer, nor should it lead to confusion the end user.

When we design a new application, we should also think at the chance to use the data types offered by the programming language we are using.

For example, if we are in c # or vb.net we can ("should") use "DateTime".
Even in SQL we have the type "Date" (and "Time").
This is the best way IMO to avoid any kind of "conversion" problem.


What do you think about it?
LVL 111

Expert Comment

by:Ray Paseur
The ISO-8601 standard provides guidance about DATETIME representations.  If you use PHP (or even if you don't) this article may be helpful.
LVL 13

Author Comment

As Ray_Paseur said, ISO is a representation of a type.
That can be used (and I suggest to) when using a strongly-typed object (date/datetime) is not possible, or we have legacy procedures that were designed to use strings or numbers to work with dates.
But ISO is for sure not a "format for humans".
No one of us, if asked for the today's date, would reply as "today is 2013 july 17".
Anyway, if one should choose a format (rather than a specific type) to be used in a program or in any computer procedure, then ISO is for sure the best one.
In fact it is also suitable for sorting purposes, since all the elements' weight are progressively lighter (year, then month, day, hour, minutes...).

That said, what you see in my article is purely my thinking, a "pattern" I pursue.
Anyone can have its own.

And, lastly, there are always exceptions to all said above.
There are procedure where you may find better to use "formats", rather than typed-data.

Featured Post

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

This is Part-2 of Learning to use the Power of Mailwasher Pro so if you haven't watched Part-1 yet, I urge you to do so before watching this video. Click this link to watch Part-1 (https://www.experts-exchange.com/videos/56638/Learn-to-use-the-POWER…
Microsoft Office 365 Backup and Restore Solution by SysTools to export Office 365 mailbox to PST / EML file format on Windows OS. On Mac, tool backup O365 to PST / MBOX / MSG / EML / EMLX file formats. Not only this, restore option helps to import s…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month