Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

date

bash

unix

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 
like image 939
John Doucette Avatar asked Oct 15 '12 13:10

John Doucette


1 Answers

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.

like image 104
January Avatar answered Sep 28 '22 01:09

January