Invalid Date generated by toLocaleString('en-gb', ...)
#42391
Labels
i18n-api
Issues and PRs related to the i18n implementation.
toLocaleString('en-gb', ...)
#42391
Version
v13.14.0
Platform
Darwin .... 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64
Subsystem
Always on Node >= 13.
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
For the record, so far I have only found
en-GBto have this problem,en-USworks as expected, see below:What do you see instead?
Invalid DateAdditional information
The day and month are swapped as of Node 13 for the
en-GBlocale.For
en-GBNode 13 seems to use the correct format day/month/year, whereas Node 12 uses month/day/year.The problem is: in Node 12 you could create a
Dateinstance based on the output of.toLocaleString('en-GB', ...). As of Node 13 this returnsInvalid Date.Node 12: the following results in a valid
Dateinstance."new Date(new Date().toLocaleString('en-GB', { timeZone: 'Europe/Amsterdam' }));"Node 13: the following results in an "Invalid Date" error.
"new Date(new Date().toLocaleString('en-GB', { timeZone: 'Europe/Amsterdam' }));"The text was updated successfully, but these errors were encountered: