1

I've noticed that the en_AU locale is defaulting to 24 hour time, it should be 12 hour as this is most commonly used in Australia.

How can this be adjusted?

Alex
  • 11

4 Answers4

4

The link Rohit provides has the answer, and it's a good one (I used it myself, and upvoted it). However, in the spirit of this, and particularly in case the link Rohit provided goes away, I'm going to write out the answer in full.

Note: this should still be considered Rohit's answer; I'm just transferring it here for posterity.

One way to do what you want would be, as Mitch says, to change your locale to one that uses the time format that you would like. However, that may entail getting other changes that you aren't interested in (Rohit's article has more on this).

More selectively, you can create a custom locale definition file with the format you want, like so:

  1. Change directory to /usr/share/i18n/locales: cd /usr/share/i18n/locales

    This directory contains locale files. The filenames are in the format <ll>_<CC> where ll is a language code (e.g. 'en' for English) and CC is a country code (e.g. US for the U.S. or AU for Australia). The idea is to customize the one you're already using (e.g. probably en_AU for the original poster - I'll use that as the example).

  2. Copy the existing file to a new file (so that you don't lose the original settings):

    sudo cp en_AU en_AU_custom

    You need to use sudo because it's a root-permissions file.

  3. Check the manual for the date command to figure out exactly what format you want for your time display:

    man date

    The manual says:

    %r locale's 12-hour clock time (e.g., 11:11:04 PM)

    which I'll use for this example. To use a different format, just adapt the following instructions accordingly.

  4. Convert your format text into Unicode. You can look up the Unicode equivalent for each character from a site like http://unicode-table.com/en/ , which tells us that % is <U0025> and r is <U0072>.

  5. Edit your new file (the one you created in step 2) with your favourite editor (gedit in the example). It's still a root-permissions file, so you'll still need to use sudo:

    sudo gedit en_AU_custom

  6. Find the section marked LC_TIME and within that, the line starting with t_fmt, which indicates the time format.

  7. Change the format to the unicode equivalent of your preferred time format, being sure to put it in quotes. For this example, the line should look something like this:

    t_fmt "<U0025><U0072>"

    Save the file and exit your text editor.

    You now have a custom locale in the file you created (en_AU_custom in the example above).

  8. Compile your new locale file into a system-readable locale definition with the localedef command (being sure to substitute your own filename if you used a different one from the example):

    sudo localedef -f UTF-8 -i en_AU_custom en_AU.UTF-8@custom   ↑ ↑ ↑     charmap your file locale definition name

    Now the new custom locale is available to the system.

    NOTE: According to the documention of the LangpackMacros class in the macros.py file of the LanguageSelector distribution package (see /usr/lib/python3/dist-packages/LanguageSelector/macros.py in your distribution), the locale filename has a standard format:

    - locale: Standard locale representation (e. g. pt_BR.UTF-8) Format is: ll[_CC][.UTF-8][@variant]

    Thanks to Andreas Storvik Strauman for pointing this out!

  9. Configure the system to use the new custom locale:

    a) edit the file /etc/environment:

    sudo gedit /etc/environment

    b) add (or, if one exists, modify) the line that defines which locale to use for time/date (the file you created in step 9):

    LC_TIME="en_AU.UTF-8@custom"

    Save the file and exit your text editor.

  10. Log out and back in to see your new format being applied.

Note: You can use the same process to modify the date/time format (d_t_fmt), date format (d_fmt), am/pm format (am_pm), standard 12 hour notation (t_fmt_ampm), and many other locale settings.

Wilson F
  • 445
  • 5
  • 20
  • 1
    +1 fixing a link-only answer deserves votes! Also, just for completion, en_AU also needs to have d_t_fmt modified. Similarly, just change <U0054> to <U0072>. – Sparhawk Feb 24 '15 at 00:44
  • Wouldn't use the name en_AU_custom.UTF-8 as it would break Language Support (gnome-language-select). At least on 18.04. Rather call it en_AU@custom.UTF-8 – Andreas Storvik Strauman Apr 20 '20 at 07:43
  • Hi @AndreasStorvikStrauman. Thanks for the tip! Would you mind providing a link to further information about that, please? I'll be happy to edit my answer, but I'd like to provide a link for people who want to delve into it and learn the underlying reasons. – Wilson F Apr 21 '20 at 20:33
  • The main reason is that the built in main language selector code in 18.04 splits the language on _ to separate region from country. However I noticed that it split "variant" on the @ symbol. I haven't looked for any documentation, but the python code for this is stored in /usr/lib/python3/dist-packages/LanguageSelector/macros.py on my computer at least. Hope it helps :) – Andreas Storvik Strauman Apr 22 '20 at 12:57
  • Thanks, I've updated the answer to incorporate that information. – Wilson F Apr 23 '20 at 01:02
1

Got to the symbol at the bar at the top of your screen where the time is displayed and click. Go to 'Time and Date Settings' (or similar). A settings screen will pop up. Choose the 'Clock' tab.

Alternatively go to System Settings, then Choose 'Time and Date' and then the 'Clock' tab.

You can now choose between 12 and 24 hour day.

  • 1
    Thanks, I realise I can change the display but this does not change the locale settings, which is used by programs such as Thunderbird and Lightning. Is there a way I can change the locale for en_AU to use 12 hour time? – Alex Jun 03 '12 at 08:33
1

how to do it

Restart as mentioned Customize using the above link. Check this solution as done earlier previous issue

Rohit
  • 39
0

To check which locale you currently have as your default

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.

locale

Changing the default locale is a little different on Ubuntu compared to most Linux distros, these are the steps we needed to go through to get it changed Click Here

Mitch
  • 107,631