Linux - Forcing 24-hour locale?

10

1

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.

RétroX

Posted 2011-08-24T02:27:52.713

Reputation: 203

1What commands do you use that display a 12-hour time ? – jlliagre – 2011-08-24T09:27:47.440

2@jlliagre: strftime("%c"), "preferred date and time representation for the current locale", returns a 12-hour time value for en_US. – user1686 – 2011-08-24T10:03:07.290

Answers

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.)

user1686

Posted 2011-08-24T02:27:52.713

Reputation: 283 655

1I 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 – 2015-01-14T01:27:23.230

@Thayne: I don't think so, no. (I use en_DK.utf-8 myself.) – user1686 – 2015-01-14T06:30:02.477

@ 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 – 2015-06-08T15:45:43.963

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

Hans Deragon

Posted 2011-08-24T02:27:52.713

Reputation: 513

This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

– DavidPostill – 2016-11-25T13:57:13.310

DavidPostill, I agree. But until I have the reputation points, which might take years, I replied so at least users can be made aware of the problem. – Hans Deragon – 2016-11-25T18:30:26.723