Skyaware Map: How to change date format from US Month/Day/Year to UK Day/Month/Year
Before Modifications (Default US format):
After Modifications (UK format):
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:
After modifications:
5 - Save (Ctrl+o), and Close (Ctrl+x)
6 - Go to Skyview in browser, and reload browser (Ctrl+F5)
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.
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
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?
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
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…
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.
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.
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.
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.
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.