Why can I format my dates by regional settings in Chrome but not Firefox in my Javascript application using toLocaleDateString()?

103 views Asked by At

We are developing an AngularJS application in which we would like dates formatted by the user's region. I am implementing this in the following way:

row.StartLocal = new Date(start).toLocaleDateString();
row.EndLocal = new Date(end).toLocaleDateString();
...
<td>
    <span class="baseline-item-name">{{ b.StartLocal }} - {{ b.EndLocal }}</span>
</td>
...

And I get this in the UI:

enter image description here

This is correct for 'en-US' the format of which is MM/DD/YYYY.

Then I switch my region (using Windows 10) to 'en-UK':

enter image description here

And it has no effect in the UI. At least in Chrome. In Firefox, on the other hand, I see this:

enter image description here

which is correct for 'en-UK' the format of which is DD/MM/YYYY.

So my question is: why does toLocaleDateString() work in Firefox but not in Chrome? Or in other words, is there a way to get Chrome to respond to the regional settings of the user's OS the way Firefox does, or is that just not possible with Chrome?

0

There are 0 answers