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

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 dateMo 15. Okt 15:34:11 CEST 2012:~$ dateMon Oct 15 15:33:24 CEST 2012

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


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


Have you tried the following? (which I got from the date manual pages)

# date -u +"%a %b %d %T %Z %Y"