Skyaware Map: How to change date format from US Month/Day/Year to UK Day/Month/Year

Skyaware Map: How to change date format from US Month/Day/Year to UK Day/Month/Year

Before Modifications (Default US format):

image

 

After Modifications (UK format):

image

 

1 - Make a backup copy of file script.js . This is important, as it will enable you to revert if you make a mistake or damage the file during editing.

cd /usr/share/skyaware/html/   
sudo cp script.js script.js.bak    

# To make sure that copy has been made, give following command
ls script*   

# The above command should list following files
script.js  script.js.bak

2 - Open file script.js for editing

sudo nano /usr/share/skyaware/html/script.js   

3 - Press Ctrl+W and type:

toLocaleString

then press Enter key. The cursor will jump to line starting with toLocaleString

function refreshClock() {
        $('#clock_div').text(new Date().toLocaleString());
        var c = setTimeout(refreshClock, 500);
}

4 - Add

"en-GB", {hour12:true}
inside brackets of
toLocaleString() ,
so it becomes like this:

function refreshClock() {
        $('#clock_div').text(new Date().toLocaleString("en-GB", {hour12:true}));
        var c = setTimeout(refreshClock, 500);
}

 

Before modifications:
image
 

After modifications:
image

5 - Save (Ctrl+o), and Close (Ctrl+x)

6 - Go to Skyview in browser, and reload browser (Ctrl+F5)

7 - Check the date :slight_smile:

 

Image source: xkcd: ISO 8601

image

3 Likes

I hadn’t noticed the date format until I read this.
After you pointed it out, I found it so annoying that I had to change it.

I’m in the UK and SkyAware shows with the correct (UK) date format without the need for any of the modifications that you have posted. SkyAware follows the date format of the device it is hosted on. Both of mine are set for UK date format. I suspect your mods are only required if you want SkyAware in a different format from that chosen for the host.

1 Like

My 2 Pi’s are set for time zone Canada/Eastern and one for America/Toronto. Still before modifications in script.js, the Skyaware map of all 3 showed date in US format. Please note that Canada officially follows Day/Month/Year format, like UK and most other countries of the world.

 

Even on VM on Windows 10 PC, it shows US date format as default

Debian 10.6 amd64

Ubuntu 20.02 amd64

Kali 2020 amd64

I’m in the UK too.
My feeds are with add-on packages rather than standard image installations, if that is why they are different?

I dont think so. I have following 3 Pi’s and all 3 showed US date format before I made modifications to script.js

  • Pi #1: Piaware SD card image ver 5.0
  • Pi #2: Armbian Buster image with dump1090-fa 5.0 & piaware 5.0 package install
  • Pi #3: Raspberry Pi 64-bit OS with dump1090-fa 5.0 and piaware 5.0 package install

Please note that none of these OS or dump1090-fa or piaware were upgraded from previous version.

Upon release of piaware ver 5.0 in March, I downloaded and wrote latest piaware sd card image, armbian buster image, and raspberry pi os 64-bit image to respective microSD cards, and did package install of dump1090-fa+piaware V 5.0 on last two. The first one was piaware sd card image and did not need any package install.

One of mine is a piaware image, the other is an add on package, Ubuntu on an Odroid XU4. Both display in UK format without any changes to the code…There are a number of different localisation options in Linux, time zone, keyboard, language etc. Have you set all of them to UK?

Have you also set the date format?

Thanks @LawrenceHill.

I am not at home now. Tonight I will try this method (which was given for Ubuntu) to see if it works on Raspberry Pi OS also.

1 Like

@LawrenceHill

No success by changing region, locale, keyboard settings of RPi.

I removed the modifications of the opening post, then tried sudo raspi-config and changed

  • Language to en_GB.UTF-8 UTF-8
  • Time Zone to Europe/London
  • Tried to change the keyboard layout to GB, but raspi-config refused to set keyboard layout, may be due to no keyboard plugged into RPi with headless OS.

After above failure, I restored the mods in the first post of this thread, but this time I used:
"en-CA", {hour12:true}
instead of
"en-GB", {hour12:true}
and date appeared in ISO recommended format: YYYY-MM-DD

image

That is how mine is set but I use 24 hour clock.
Mine appears like this:


I’ll try and do a bit more digging regarding localisation options on the rpi. It has always worked straight out of the box for me.

Thanks for the Tip. UK and 24hr clock suits me!

Figured I would need to do the same thing as my OCD would get the better of me seeing the date displayed in US format but when I checked my maps it was already displayed in UK format and I definitely have not edited any config file to suit.

Well as far as my tired old brain can remember in any case… :crazy_face:

-=Glyn=-

@LawrenceHill
@Humpfrey
@conligwx
@conligwx

Finally discovered following:

  1. If no modifications to file script.js are made, then the date displayed on Skyaware map depends on regional & Language settings of the computer on which skyaware map is being displayed. It does NOT depend on the language or regional setting of RPi or My ADSB cog wheel settings.

  2. If modifications in file script.js are made as shown in opening post of this thread, that particular date format is displayed on skyaware map displayed on all computers, irrespective of those computers’ language & regional settings.

 

1 Like

Yes, of course, it is related to the date format set in the viewing browser (which may not be the same as the computer it is running on). So the solution is to fix the problem with the browser settings.

Yeah I know, since the is script is run on the local web server, anything visiting the page will see that time stamp format.

That is one solution, and has to be repeated on every computer and every browser one wants to view the map.

The other solution is to fix it in script.js which makes skyaware date setting independent of computer and browser settings.

 

Fixing it in the browser fixes the date display for all web pages you visit, that use JavaScript (which is most). If your date format settings are wrong the you will be seeing annoying incorrect dates everywhere.

My problem was not browser settings. It was Windows 10 settings.

  • If I set Windows to US, date displayed in Skyaware is MM/DD/YYYY, which is very annoying and confusing.
  • If I set Windows to Canada, date displayed in Skyaware is YYYY/MM/DD which looks unfamiliar as no one here writes Year first. This is ISO standard and good for databases, but not for day to day use by humans.

That is why I went to add "en-GB" in script.js to make Skyaware date appear in format of my choice i.e. DD/MM/YYYY, and which is the one people normally use in Canada.

1 Like

Sorry, but I beg to differ. The browser picks up its settings from the OS but if you don’t like the format you have selected for the OS, it is possible to set the browser to use a different format from the OS.