Forcing "date" to use a locale other than the machine default

Sure, you can always specify the format yourself:

date +%a, %b %d

or you can use a temporary environmental variable:

:~$ LC_ALL=de_DE.utf8 date
Mo 15. Okt 15:34:11 CEST 2012
:~$ date
Mon Oct 15 15:33:24 CEST 2012

As you see, only the first command is run with the German locale.


LC_TIME is enough, you can use this.

LC_TIME="de_DE.UTF-8"  date

You can modify the environment date runs in. I don't know if this is the best way (the variables used in locale handling are numerous), but the following works:

$ LANG=de_DE date
Mo 15 Okt 2012 09:34:12 EDT

(January beat me to this answer by a minute or so, but I'll leave my answer up in the hopes that some will clarify which variable (LC_ALL, LANG, other) is most "appropriate".)

Tags:

Unix

Bash

Date