Alex Rivera | Logout

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

Asked 2012-10-15T13:21:17.030
46

Is there a way to force the *nix command "date" to output in a specific format independent of the local? For example, if I call "date -u" today, on a US machine I get:

Mon Oct 15 13:15:29 UTC 2012

but on a German machine I get:

Mo 15. Okt 13:15:31 UTC 2012
Edit
Report

1 Answer

18

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

answered 2012-10-15T13:35:19.440

Your Answer