Why "Last visit was at" + someDate.toLocaleDateString (); is it a bad habit?

When reading a JavaScript link to a Date object from the Mozilla Developer Network , I get this note:

You should not use this method in contexts where you rely on a particular format or locale.

 "Last visit: " + someDate.toLocaleDateString(); // Good example "Last visit was at " + someDate.toLocaleDateString(); // Bad example 

Why?

+4
source share
2 answers

Because in other languages, this way of writing dates does not make sense. In Spanish, for example, you would say:

 "La última visita fue el 27/03/2012 a las 14:04" 

So, if you simply write "Last Visit:", you will avoid the date date format.

+1
source

Because it can be illogical English if you get a locale string.

It depends on what country you are in, what String looks like.

0
source

All Articles