The Date.toLocaleDateString() doesn't work in my Windows 10 laptop running nodejs (v10.15.0) as server for a discord.js bot. It shows mm/dd/yyyy instead of dd/mm/yyyy.
I'm using 'en-GB' as the first argument for locale, and second argument for the format I want to achieve (dd/mm/yyyy). And in https://js.do/ , it displays dd/mm/yyyy, but somehow in my laptop it shows as mm/dd/yyyy, and they're both using the same code except for "document.write", I used "console.log" for displaying the result.
let d1 = new Date();
let options = {
year: 'numeric',
month: '2-digit',
day: '2-digit'
};
document.write(d1.toLocaleString('en-GB', options)); // console.log in my laptop
I would expect it to be dd/mm/yyyy format because it's in 'en-GB' locale, instead of the mm/dd/yyyy format.
What is the problem? Is it because of nodejs? or the js.do website? As discussed in this thread: Date.toLocaleDateString() not working on Nodejs v10.14.2 , but I think the issue is slightly different.