What is the "formal" name of MySQL's DATETIME format?
Asked Answered
W

2

6

Does anybody know the formal name of the YYYY-MM-DD HH:MM:SS date format used by a MySQL DATETIME? Is there one? It looks close to ISO 8601, but it's different enough to break in most applications if you try to use the two interchangeably.

Sometimes I find myself needing to refer to this particular format in conversation, but referring to it as "the DATETIME format" always draws blanks from those who haven't done much work with databases. I'm accustomed to date formats having official names and extremely formal definitions. (RFC 2822, anyone?) So, does one exist?

Woo answered 6/12, 2012 at 14:56 Comment(5)
I would have thought that is the ISO format. What is the difference to the ISO format?Motheaten
It's close, but ISO has a T separating the date and time components instead of a space character.Woo
The ISO definition states that the T can be left out if no abmiguity is to be expected (at least that's what Wikipedia says)Motheaten
Perhaps. But as a practical example, the JavaScript Date object in Firefox 17: isNaN(Date.parse('2012-12-06 12:15:00')) === true and isNaN(Date.parse('2012-12-06T12:15:00')) === false. The T does seem to make a difference in some applications.Woo
@Woo the ISO standard is quite extensive and covers many variations. Sadly it's not open for anyone to read. Javascript supports a very restrictive subset.Homer
L
4

MySQL's Date and Time Literals are described in the reference manual. AFAICS, there's neither ISO nor any other name mentioned.

Wikipedia, ISO 8601 shows the ISO combined date and time format, which is "2012-12-04T20:03" ("YYYY-MM-DDTHH:MM") and differs from the mentioned MySQL datetime format.

So, although it looks roughly like an ISO datetime, I would just call it MySQL or SQL format.

Linesman answered 6/12, 2012 at 15:36 Comment(0)
B
3

2021

Olaf Dietsche's answer is right but old (2012) & slightly inaccurate as of 2021. According to Wikipedia ISO 8601:

As of ISO 8601-1:2019, the basic format is T[hh][mm][ss] and the extended format is T[hh]:[mm]:[ss]. Earlier versions omitted the T (representing time) in both formats.

Also from same link:

ISO 8601-1:2019 allows the T to be omitted in the extended format, as in "13:47:30", but only allows the T to be omitted in the basic format when there is no risk of ambiguity with date expressions.


MySQL in their documentation mention "ISO" (with no number), in one link they did mention that ISO format refers to ISO 9075, not ISO 8601..

ISO 9075 is basically MySQL standards.

btw, ISO 8601 & RFC 3339 are pretty much the same thing (from developers' perspective). In case you are interested, read.


Bottom line:

MySQL datetime format matches same format of ISO-8601 / RFC-3339 , although MySQL has its own standard ISO 9075. So, for the MySQL datetime format, we can refer to it as any of the below:

  • ISO 8601 aka RFC 3339
  • MySQL format aka ISO 9075.
Binkley answered 16/6, 2021 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.