10

Is there any way to force 24-hour time in my locale (for example, 14:00) instead of 12-hour time (2:00 PM)?

I use the en_US locale with a UTF-8 character set on Arch Linux, but this shouldn't matter, I think.

  • 1
    What commands do you use that display a 12-hour time ? – jlliagre Aug 24 '11 at 9:27
  • 2
    @jlliagre: strftime("%c"), "preferred date and time representation for the current locale", returns a 12-hour time value for en_US. – user1686 Aug 24 '11 at 10:03
7

Locales can be set for various components separately, so you can set LC_TIME to either "en_GB.UTF-8" (Great Britain), "en_DK.UTF-8" (Denmark – ISO 8601 time), or "C" (no locale).

(Don't forget /etc/locale.gen.)

| improve this answer | |
  • 1
    I have tried using en_GB.utf-8 for LC_TIME, but that has the unwanted side affect of swapping the position of the month and day in the short date format. Is there any way to JUST change the preference for 24 or 12 hour time? – Thayne Jan 14 '15 at 1:27
  • @Thayne: I don't think so, no. (I use en_DK.utf-8 myself.) – user1686 Jan 14 '15 at 6:30
  • @ Thayne - I think you'd need to create and install a locale definition of your own, using en_US as a starting point. – Toby Speight Jun 8 '15 at 15:45
1

As @grawity reports, you can try to find another locale for LC_TIME, but you will always have granularity problems, always compromising between options. This is a known problem and I suggest that you add yourself to the following bug report: Ubuntu Lauchpad bug #1392699

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.