Date.toLocaleDateString() is wrong! ...how to fix it?

Arnaud Dagnelies - Feb 11 '22 - - Dev Community

Let's cut to the chase with an example:

new Date('2022-02-09').toLocaleDateString('de-DE')
Enter fullscreen mode Exit fullscreen mode

This outputs 9.2.2022 ...which is the wrong format!

The common expected format would be 09.02.2022!

The first one is not 100% wrong though, it's more like an unusual but tolerated format in Germany. However, what shows in the windows task bar, in apps, in official documents, and so on, is always 09.02.2022 here in Germany. The other just shows sometimes up in handwritten letters.

There are countless related bug reports complaining about this on the web, in all kind of unrelated projects, since ages. Still, it doesn't seem to budge.

So I tried to dig up the "official" format:

I must confess that despite searching for quite some time, I failed too to discover where this "wrong" d.m.yyyy comes from. Despite every browser seem to implement it, I haven't found the official reference regarding these date format patterns.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .