How can I change date and time locale?
toLocaleDateString and toLocaleTimeString return date in "%m/%d/%Y" and "%I:%M:%S %p" formats, while I want them to use "%Y-%m-%d" and "%H:%M:%S" formats. What settings/environment variables should I change?
OS: Mint 19 tara Kernel: x86_64 Linux 4.15.0-20-generic Mozilla Firefox 63.0.3
`/usr/bin/locale' outputs: LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_CTYPE="en_US.UTF-8" LC_NUMERIC=ru_RU.UTF-8 LC_TIME=C LC_COLLATE="en_US.UTF-8" LC_MONETARY=ru_RU.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=ru_RU.UTF-8 LC_NAME=ru_RU.UTF-8 LC_ADDRESS=ru_RU.UTF-8 LC_TELEPHONE=ru_RU.UTF-8 LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=ru_RU.UTF-8 LC_ALL=
Todas las respuestas (2)
I think the time and date is base on you O/S.
You can include a locale and a JSON options parameters, so maybe try if you can find a locale that orders the items like you prefer.
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString