1

This question already has an answer here:

On Linux Mint Rebecca, my current LC_TIME setting is LC_TIME="en_US.UTF-8"

I would like to execute date and watch how the current date is displayed in a Chinese format with Chinese characters.

Therefore, I thought I have to set the LC_TIME variable this way:

LC_TIME=zh_CN.UTF-8

however, when I execute date I still get the date in the English style format, moreover when I execute locale I see the LC_TIME variable did not change its value at all.

Output of locale -a:

C
C.UTF-8
de_DE.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

marked as duplicate by Gilles command-line Mar 24 '15 at 13:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • On what distribution? What is the output of locale -a? – Gilles Mar 23 '15 at 23:04
  • C C.UTF-8 de_DE.utf8 en_AG en_AG.utf8 en_AU.utf8 en_BW.utf8 en_CA.utf8 en_DK.utf8 en_GB.utf8 en_HK.utf8 en_IE.utf8 en_IN en_IN.utf8 en_NG en_NG.utf8 en_NZ.utf8 en_PH.utf8 en_SG.utf8 en_US.utf8 en_ZA.utf8 en_ZM en_ZM.utf8 en_ZW.utf8 POSIX – Abdul Al Hazred Mar 23 '15 at 23:29
  • On what distribution? You need to generate the zh_CN.UTF-8 locale; how to do that depends on the distribution. – Gilles Mar 23 '15 at 23:38
  • it is linux mint codename rebecca – Abdul Al Hazred Mar 24 '15 at 12:07
3

date is separate from your shell, so unless you instruct your shell to modify the environment date sees, your changes to LC_TIME won't have any effect.

You can fix this in two ways; either by specifying a value for LC_TIME only for date:

LC_TIME=zh_CN.UTF-8 date

or by exporting LC_TIME so its new value is given to all subsequent processes started by the shell:

LC_TIME=zh_CN.UTF-8
export LC_TIME
date

You'll find more detail in Understanding environmental variables in different contexts

  • 1
    LC_TIME=zh_CN.UTF-8; export LC_TIME; date did work in so far that LC_TIME variable indeed changed its value, but the date command still display an english formatted time. – Abdul Al Hazred Mar 23 '15 at 14:47
  • I had to use LC_ALL for it to work. (Setting LANG and LC_TIMEdid not work). – thomasa88 May 29 '18 at 13:42
  • 1
    @thomasa88 that suggests you already had LC_ALL set to something else — it overrides all other LC_ values. If you unset LC_ALL, LC_TIME should work fine. – Stephen Kitt May 29 '18 at 13:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.