Is there a way to change the date format in the web interface?

alert(new Date(2013, 9, 25).toLocaleDateString());
Returns 10/25/2013

alert(new Date(2013, 9, 25).toLocaleDateString(“en-AU”));
Returns 25/10/2013

System locale is “en-AU”, and apparently my browser sends “Accept-Language en-GB,en-AU;q=0.5”.

Ah ok, so it does work as intended. You need to fix the locale the browser uses.

The thread was about it using DD/YY/MM in Australia, something totally wrong…

I’ve done a clean install of Ubuntu. According to “http://www.localeplanet.com/support/browser.html”, my “navigator.language: en-AU”.

But still getting the backwards dates. It works fine if I change var lds = y.toLocaleDateString(); to var lds = y.toLocaleDateString(navigator.language); in the urbackup functions js file. This should work for Chrome and Firefox, but may break in IE.

8 months later and this still seems to be an issue. I’ve just come accross this thread while researching the same problem. In the UK and getting USA date format on Chrome, EdgeDev, and Brave. Oprea is OK.
On the Windows server I have fixed this by changing ‘var lds = y.toLocaleDateString();’ to var lds = y.toLocaleDateString('en-GB'); in the urbackup functions js file (similar to the fix above but does not rely on the browser language being correctly set.

Considering this is an ongoing issue, would it not be better to allow a locale variable to be specified in the server settings? It would provided consistency and not create a bunch of ‘hoop jumping’ to get to a solution.

Please open a new thread – this was about a solved issue.

Seems Chrome doesn’t use operating system settings. Changing the language in the advanced Chrome settings changes the date format. Change it e.g. from English (United States) to English (United Kingdom).


The issue isn’t fixed though. It still shows the wrong date format in the latest version when the intended locale isn’t passed to the JS function. Null returns the browser’s compiled locale, not the current system one. If other browsers now present the same problem, perhaps this is the intended behavior of the JS function now.

The thread is about UrBackup showing the dates in DD/YY/MM format in Australia. That was fixed.

Solution…go to settings in Firefox and change the language to UK English to achieve the dd/mm/yyyy format

Hi, maybe beating a dead horse here but I wanted to figure this out.

Looked at the code determining which date to be used. It followed the display language of Firefox and that made me a bit curious. I wanted it to follow the primary host header language, which I’ve set to sv, sv-SE.

Found this. Changing one row var lds = y.toLocaleDateString(); to var lds = y.toLocaleDateString(navigator.language); looks like it solved it.

So in, file: urbackup_functions.chash-cb06117b2b923bb8b72f1ea5eeac5557.js

function determine_date_format()
{
	//Create a known date string
	var y = new Date(2013, 9, 25);
	var lds = y.toLocaleDateString();
...

With this, inserted navigator.language for toLocaleDateString:

function determine_date_format()
{
	//Create a known date string
	var y = new Date(2013, 9, 25);
	var lds = y.toLocaleDateString(navigator.language);
...

I’m by no means a javascript person so this may break allot, I can’t tell :grinning:
But after this modification I always get right locale format of dates.

Well, ideally (on Windows) it would follow the system wide date format setting (or LC_TIME on Linux). I.e. here I changed it to the ISO format for testing:

But I just checked, and this only seems to work with Internet Explorer, not even Edge :(.

So it seems, this really needs a change. Set it to the current selected language, with navigator.language as default?

Hi,

I understand what you reaching for.

Looked around a bit and trying to figure out the system locale from a browser session with javascript seams to be a mess. My 2c here is that you have to presume that locale should follow the language choice maybe.

This way of determine the browser preferred language should be a little more x-browser compatible what I’ve google/stackoverflow-knowlage my way to (https://stackoverflow.com/questions/673905/best-way-to-determine-users-locale-within-browser).

y.toLocaleDateString(navigator.userLanguage || navigator.language || navigator.browserLanguage || 'en');

It also has a fallback to en, en-US if I understood it correctly

Tried the above in Firefox, Edge and Internet Exploder :slight_smile:, Works. I don’t care for Chrome and don’t have it installed so that is left to test.

Brgs,

I was able to persuade Firefox to give me the format I wanted. All I had to do was change the “Language” setting on the FireFox options page from English (United States) to English (Canada). With the US English I get dates like “03/07/20”; with the Canada setting they become “2020-03-07”.

The options page is indicated by a gearwheel in one of the icon areas. If you can’t see it, click on the hamburger icon and you should see the gearwheel about half-way down.

Once in the options page, look for the Language item. There may only be one language in the drop-down, it’s straightforward to add more.

Maybe urbackup could offer a custom date format setting, so that it wouldn’t have to depend on the amazingly complex way that browsers choose how to format dates now.

1 Like