Changing the Displayed Date Format in Ubuntu Linux: a Geek Odyssey

This morning I noticed that Thunderbird (on my new virtual Linux machine) was showing message dates in the confusing 06/10/07 format. I much prefer the ISO standard date format (2007-06-10) — not only does it prevent confusion about which is the day and which is the month, it also comes out in the proper order when text-sorted, which is sometimes quite useful. “No problem, I’ll simply change it,” thought I. “How difficult can it be?”

I should have known that asking a question like that never has a good outcome.

Under Windows XP, changing this is a simple matter. You just go to the Control Panel, click on the option labeled “Date, Time, Language, and Regional Options”, click on the option “Change the Format of Numbers, Dates, and Times”, and use the fairly-easy-to-understand dialog that appears. Earlier Windows versions are slightly different, but all of them have a similarly simple setup. I expected something similarly easy in Ubuntu Linux.

Wrong!

Changing the format in Linux is simplicity itself. But finding the information on what to change and how to change it is difficult bordering on ludicrous.

I found this page, which shows how to make Thunderbird’s dates work properly. That’s nice, but that’s not what I wanted — I wanted all of my programs to use that date format. This one mentioned something similar, enough to show me that it could be done, but no mention of how to do it. It led me here, which gave me instructions on how to do exactly what I wanted — instructions that unfortunately didn’t work at all, as the file ~/.bash_profile is apparently completely ignored under Ubuntu Linux. Putting those lines in ~/.bashrc instead (as suggested here) worked, but only for programs that I started up via the terminal window — unacceptable.

This command would show me what “locale” settings I was currently using, but didn’t offer any way to change them. This one is supposed to change them, but is so convoluted that I wasn’t able to figure out how to do so. Somehow I stumbled onto this page, which explains some of how to work it. After reading the “issues” section near the bottom, I wasn’t too keen on it, but I decided to try it out anyway.

It’s a good thing I just had a haircut this week. If my hair were long enough to get a good grip on, I’d be bald by this point, because there’s no directory /etc/env.d on this system.

However, before I could start rending garments and gnashing teeth, I noticed another file in the /etc directory, called environment. On a hunch, I opened it. Eureka!

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" LANG="en_US.UTF-8" LANGUAGE="en_US:en"

With trembling fingers, I added another line to it:

LC_TIME="en_DK.UTF-8"

Control+Alt+Backspace restarted the GUI. Opening a terminal window and typing locale showed me that everything was set to en_US.UTF-8, except the LC_TIME format, which was en_DK.UTF-8 — exactly as it should be! Finally, the acid test: I opened Thunderbird and clicked on a folder that I knew had older messages visible. IT WORKED!

Linux usability has come a long way in the last six years or so, but there are still a number of areas that require improvement. This is most certainly one of them. I had to spend hours researching this, trying to make a change that should have been a matter of seconds. Is Linux ready for the desktop? Maybe some desktops, but not all.

10 Comments

  1. And I thought setting global environmental variables in Solaris, more neccesary under ordinary circumstances (to get all of the long pathnames of blastwave, gnu, and other non-default paths, to work everywhere), was arcane and annoying. It’s actually more centralized and documented.

    Of course, most people don’t have the need to make everything have a non-country-standard date format, so I don’t know if it’s enough to say “not ready for the desktop”. Even XP’s environmental variable settings are in the “advanced” tab. (I needed them to play with Inferno.) – but there’s other times you’d want to change environmental variables in a way that everything “gets” them.

  2. It wasn’t even so much that the information was difficult to find. It’s that there was so much misinformation out there. Some people complain that there are too many ways to do the same things in Windows, but at least all of them work! Three-quarters of the stuff that I found out there didn’t work at all, or maybe just didn’t work on this particular distribution.

    I’ll stand by my assertion: as good as it has gotten, Linux still isn’t ready for all desktops.

  3. Well, you do have to make sure it’s your distro, or at least one that’s closely related (like Debian and Ubuntu). Unfortunately there’s fragmentation in the Linux world. That’s why I invested in Nemeth, Snyder, and Hein’s “Linux Administration Handbook”, which covers Red Hat, SuSE, Debian, and Ubuntu. Of course, you could run Arch Linux where a lot of /etc configuration is in the one /etc/rc.conf file and the rest is kept simple, stuff like a Slackware-like BSD init system. 🙂 )

    (But unfortunately, arch is more of an intermediate to expert distro. I do miss SuSE’s /etc/rc.conf from the 7.x days before they embraced the LSB standards for configuration files. (Debian distros have not, hence the misleading advice about /etc/env.d) That distro was, once upon a time, both GUI driven and had reasonable /etc files, making it a good choice for both novices and intermediate users. However, today, not only does SuSE have less decent /etc files, it still has a lousy package management system, actually, three lousy ones – which makes it a loss in spite of the GUI YaST configuration tool. Nowadays the package manager is a big part of the user experience. (Everybody offers the same basic GUIs usually, even if not installed by default, though not configurators like the ones in SuSE, PCLinuxOS, or Mandriva. Of course, since I prefer working with text files, I hate such tools – especially since half the time they stomp all over your changes.))

  4. The page that suggested putting commands into ~/.bash_profile was for Debian, which is part of why it was so baffling that it didn’t work in Ubuntu.

    Nevertheless, I’m sticking with Ubuntu for now. I’m not using Linux to play with different distributions, after all, I’m using it to get work done.

  5. Odd, that would work in some circumstances but not others. It would work if you booted into a command line environment, and also if from that environment you ran “startx” to run the GUI. Possibly also with XDM, X11’s ugly desktop manager, but I think not with GDM; the desktop manager of the GNOME project used by Ubuntu.

    That was bad advice, though considering the way many Debianites run their systems, Debian is a bit of an intermediate to advanced distro where a graphical login screen would be seen (properly) as a technical liability rather than a user-friendly feature (what about if there’s something wrong with X11?), it would probably have worked for the author of the advice and a lot of the readers of it.

  6. The ~/.bash_profile stuff didn’t seem to work at all, under any circumstances. I rarely boot into a command-line-only environment though, it might have done so there. I doubt it though, because I believe the system boots up that way (via a bash script), and even rebooting the system didn’t activate it there.

    I’d like to figure out why it didn’t work, for future reference, but I’m not too worried about it.

  7. No, ~/.bash_profile executes only for an interactive login shell, or a shell that is executed with the -l flag. (read “man bash”, I knew the former though already) It isn’t going to work simply by booting if you’re going into GDM or the like.

    At any rate, it’s good you found a solution. Even I didn’t know about /etc/environment, though I knew such a file (or in the case of /etc/env.d, any number of executed files – the .d convention means a directory with multiple text files, makes it easier for tools and for careless editing not to mess things up, at the cost of complexity in maintaining – though of course it makes sense for the init files) exists in the typical distro.

    I never needed /etc/environment or the like though, I always dealt with the default locale’s date displays without complaint, like the typical user, for whom the Linux desktop is ready. 😉

  8. Silly me, I figured that the shell that starts up the graphical login screen was a login shell.

    And just because most typical users are willing to accept the defaults does not mean that it’s okay for the OS to ignore those who don’t. I’m not accusing anyone of anything — I know how building software works, better than most, and I know that this is probably very low on the priority list — but someone could at least make the information easily accessible to those searching for it. Which I hope that it now is, via this blog page and Google; that’s one of the main reasons I wrote it.

  9. No, a login shell is when you get a shell from a login prompt or executed with the -l switch. The graphical login screen fires up a GUI environment… That having been said though I have also wished before it operated a bit more identically, even Linux has cruft, and non-intuitive features, and this is an instance of that; definitely. Though it could change other behavior to fix that, how would you deal with shells fired up from windows when they technically are usually not login shells and you don’t necessarily want them to be (considering other things login shells are supposed to do.) Of course, as you point out, the solution is to document /etc/environment, and plead with google to remove all links to advice about putting it in your login shell’s profile. 😉

    “but someone could at least make the information easily accessible to those searching for it. Which I hope that it now is, via this blog page and Google; that’s one of the main reasons I wrote it.”

    I think Ubuntu also has a Wiki.

  10. I’m looking at it now, and trying to see where this would fit in. There’s no obvious category for it, like customizations.

Comments are closed.