Change date format globally in Ubuntu

Recently, I was twice asked about how to change the date format in Ubuntu. I have never bothered to tweak this part in my own setup. So, when asked, I assumed it would be easy to do at first. However, upon searching the Ubuntu desktop, I couldn’t find anything that might change the date format globally.

Sure, you could change it for Nautilus or Evolution in their respective Preferences dialogboxes. But where is the global one setting to rule them all? Thus, my hunt online began. Surprisingly, this “problem” was not well known and it took a bit of digging before I find the fix. Previously, I posted about the less than stellar format thumbdrive use case. In my opinion, here then is another fundamental use case that Ubuntu failed to provide adequately.


Now, there could be argument that I am missing the point. To explain this, we need to understand how the date format is determined in an Ubuntu system.

In Ubuntu (and possibly many Linux systems; I am not an expert here), a number of settings like location, language, timezone, time and date format, etc are lumped into what is called locale. Each country and/or region in the world is assigned a specific locale. You can find out what locale is assigned to your Ubuntu installation by typing this in the command line:


For example, this is what I get for my system:


So, being located in Singapore, my locale has been set to “en_SG”. Somewhere deep in the system, this designation will determine how the date is formatted (plus other things). If, for example, the date format is incorrect, the proper process is to file a bug to get it corrected in the next patch. All is good.

Counter argument

Well, technically. Things such as location is fixed. “en_SG” is assigned to location Singapore, no argument there. But not everyone has the same preference on how they want the date format to be. In one locale of many users, there is bound to be different preferences. Not allowing easy customisation here is basically silly.

Until this is fixed (if ever), there is no intuitive way to change the date format. But like many things Linux, workaround is entirely possible.


By default, here is how the date/time appeared in Nautilus for my system:

Nautilus: date

To change the date format, you edit the corresponding file under “/usr/share/i18n/locales/”. For my locale, it’s “/usr/share/i18n/locales/en_SG”.

gksudo gedit /usr/share/i18n/locales/en_SG

First, change the date/time format. Locate the keyword “d_t_fmt”. Here is how it appeared in my system:

% Appropriate date and time representation
% %A %d,%B,%Y %I:%M:%S  %Z

Make sure that the d_t_fmt line remains a single line (I have to break it up here into multiple lines for illustration because it’s too long).

This looks more complicate than it actually is. The codes are equivalent ASCII characters codes (UTF8 to be precise). You can decode it by referring to the tables here.

I would like to change the full weekday and month names to the abbreviated names. Monday becomes “Mon”, Tuesday becomes “Tue”, etc. And January becomes ‘Jan”, February becomes “Feb”, etc. I am also replacing the commas with spaces.

To do so, I change the “d_t_fmt” to:

% Appropriate date and time representation
% %a %d %b %Y %I:%M:%S  %Z

Ok, that wasn’t so easy, because humans are not made to decode ASCII on-the-fly.

One more part to change: the “d_fmt”. From:

% Appropriate date representation
% %A %d,%B,%Y
d_fmt "<U0025><U0041><U0020><U0025><U0064><U002C><U0025><U0042><U002C>


% Appropriate date representation
% %a %d %b %Y
d_fmt "<U0025><U0061><U0020><U0025><U0064><U0020><U0025><U0062><U0020>

Of course, you could further modify the time format under ‘t_fmt”, if you so desire. Save and exit the text editor. Then, run this command to apply the changes:

sudo locale-gen

Logout and login again to see the new settings.

Here is how the date/time appeared in Nautilus for my system afterwards:

Nautilus: date

Nautilus customisation

Of course, you could skip all these hassles if you don’t mind the simpler date/time format available within Nautilus preferences.

Nautilus: preferences

Setting to numeral date/time representation gives you this:

Nautilus: date


After tinkering with the locale, i started looking at other things I might customise, and found the first day of the week setting. By default for my locale, the first day of the week is set to Sunday. You can see this from the panel calendar:

Nautilus: date

I’m not sure the “official” first day of the week for Singapore, but since the normal office hours here are Monday to Friday, it is more logical (and convenient) to assign Monday as the first day of the week.

To change this, edit the appropriate “/usr/share/i18n/locales/” file again. Change “first_weekday” keyword from 1 to 2:

%  FIXME: found in CLDR
first_weekday 2


sudo locale-gen

And logout and login again. Final result:

Nautilus: date


I am realising the steps above is quite long winded for something so basic. It should be relatively straightforward to code a GUI application to do this. Not sure if I can be bordered to do this personally though.

Comments 13

  1. lametike wrote:

    hey…maybe there is a better way of ajusting time!
    you could just go to the time bar at the top left corner and then you right click the time and select adjust date & time!

    Posted 20 Nov 2008 at 8:20 pm
  2. chewearn wrote:

    hi lametike
    Thanks for reading my blog and leaving a comment. Hope to see you again in the future. :)

    Posted 20 Nov 2008 at 11:12 pm
  3. xeres wrote:

    Excellent work! Thank you for this tutorial. I’ve been looking to change this for quite some time — particularly having Monday as the start of the calendar week, not Sunday. Again, thank you!

    Posted 14 Aug 2009 at 11:41 am
  4. chewearn wrote:

    hi xeres
    You are welcome! :smile:

    Posted 14 Aug 2009 at 2:00 pm
  5. igor wrote:

    Thank a lot! You helped me to solve the annoying problem with the date format in Icedove/Thunderbird!

    Posted 28 Sep 2009 at 6:21 pm
  6. chewearn wrote:

    hi igor, glad it was helpful. :smile:

    Posted 28 Sep 2009 at 8:55 pm
  7. Chris wrote:

    I could not follow how to change the date Nautilis shows here in the UK.
    The local is set correctly as en_GB but for the field “date modified” this is displayed “2010-07-29 18:50:45″ but in the UK the year is written last. (Ideally to save space the format dd-mm-yy would be best which would display as 29-07-10.)
    This is in Ubuntu 10.04
    Should I perhaps just report it as a bug or do you have a help for me?

    Posted 30 Jul 2010 at 6:49 am
  8. chewearn wrote:

    hi Chris
    As far as I could figure out, the “short date” format in Nautilus is built into Nautilus itself, i.e. it’s not part of the locale setting. In other word, nothing short of hacking Nautilus code itself.

    However, as a workaround, I figured it is possible to change the “long date” format to be “DD-MM-YY HH:MM:SS” following my guide above (it’s just not an entirely trivial modification).

    First, you need to change abmon (abbreviated month names) parameter to be 01, 02, 03, and so on. Then, change d_t_fmt to “%d-%b-%Y %I:%M:%S”.

    Only thing is, the long date will be effected globally in every application that uses it.

    Posted 30 Jul 2010 at 8:53 pm
  9. Chris Sterling wrote:

    Wow Chewearn. Three years later and this blog post is still helpful to people. Thanks to you I’ve been having some fun messing around with my time and date formats. Thanks so much for making this blog post. It sure is surprising that this isn’t all easily editable in a standard control panel GUI, but it could be worse.

    Posted 08 Jul 2011 at 7:58 am
  10. chewearn wrote:

    Hi Chris, thanks for leaving a note. It is very encouraging to know this post is still useful.

    Posted 08 Jul 2011 at 9:03 am
  11. Neo Cambell wrote:

    If you are using Ubuntu, here is an easy way.


    Posted 06 Jan 2012 at 7:23 am
  12. chewearn wrote:

    hi Neo
    It’s possible, but not an entirely proper workaround. For instance, if I am in US, my currency is Dollar. But if I changed to UK, then it becomes Pound.

    Posted 07 Jan 2012 at 12:04 am
  13. Scuzzball wrote:

    Many thanks, always have to look up how to do this.

    Posted 05 Dec 2012 at 8:26 am

Post a Comment

Your email is never published nor shared. Required fields are marked *