How to format dates

Posted in General, published on

It's been a pet peeve of mine for quite some time: formatting dates. Sometimes I really hate other people for the way they format dates. If you're a programmer or computer poweruser you will get what I mean even more.

There are probably thousands of ways to format dates, but there is only one correct way. Of course I'm talking about glorious ISO8601!


ISO8601 provides a beautiful way to format dates. It's simple, clear and easy to understand.

2019-08-09 is the date on which I'm writing this post. It's august 9th, 2019.

The format is very simple and if you can read you can understand it. Year, Month, Day.

YYYY-MM-DD is logical. When you think about it, a year is bigger than a month. A month is bigger than a day.

No more nonsense, I'm looking at you USA! No more 08-09-2019, is that september 8th or august 9th? Also, forget about using a slash, the hyphen is the way to go!

ISO8601 rules

For some reason you have to pay to download (ie read) an ISO standard. Luckily there is a very informative Wikipedia article on ISO8601.

I have listed some key take aways below.

For writing a date:

  2. Use 4 digits for the year, 2 for month and day. Add zero-padding if needed

For example: 2019-08-09

For writing a date and time:

  2. Use 4 digits for the year, 2 for month, day, hour, minutes and seconds. Add zero-padding if needed
  3. Use 24 hour time format
  4. Seconds can be omitted if desired
  5. Specify the timezone

For example: 2019-08-09T14:23+02:00