How can I get the string dd.mm.yyyy in JavaScript and convert it depending on the user’s locale (for example, дд.мм.гггг)? Is it possible with the help of internal functions, or will you have to write your own converter?
I tried to find a solution in Datе and Intl.DateTimeFormat, but I didn’t find it there.
3
Answers
I don’t think you will be able to do this without a hard coded function. But maybe something like that can fit your needs:
Here the documentation for more options.
If you need to get the format from a string, you’ll need to use a library like moment:
https://momentjs.com/docs/#/parsing/creation-data/
The answer is no. There is no way you can get дд.мм.гггг from _RU or dd/mm/åååå for Norway/Denmark using plain JS/INTL
Here is the closest you can get using a lookup table with a locale as input
Here is IMNHO OK hack for moment
You can try using the
lang
attribute, but browsers are unlikely to implement it. Second-best is to have aplaceholder
being changed based on the chosen language: