10

I currently have the task of building an EE site in Chinese. All is going well so far, but I have a problem trying to get the date shown in chinese. Anyone have a solution to this?

I'm just using the following standard date code at the moment:

{current_time format="%l %j%S %F, %Y"}
  • 1
    You know, I think if you set the locale on your server it might just do it automatically. Try adding setlocale to your index.php file. – Adrian Macneil Nov 22 '12 at 12:04
10

Firstly - you need to check that your server has Chinese Encoding installed - if it does, then what you need is the plugin that I wrote many years ago:

Date/Time Language Converter

You can then use this plugin to wrap your date/time value and specify the language and it'll format it in the appropriate language.

  • 1
    Thanks for this Carl. I've got the plugin working, although I had to set the format to the following: {current_time format="%U"} which creates a unix timestamp for the plugin to convert from. – Jim Pannell Nov 22 '12 at 13:35
2

You can also just install the Chinese language pack. This will also convert the CP to Chinese, but you can set a language preference per user to override it.

1

What format do you need to output?

So I'm not a Chinese speaker, so will very happily defer to anyone who knows more than me, but as I understand it the convention is to format the date "Year Month Day", with each value followed by the relevant character 年 (nián) for year, 月 (yuè) for month, and 日 (rì) for day. Assuming that you are using a utf-8 charset can you not just do: {current_time format="%y年 %m月 %d日"}

If you need to output the day of the the week or a more complex format though it looks like you might be best off with @madebyhippo's plugin, which looks super flexible.

  • Thanks Tom - I've gone with @madebyhippo's plugin and it's working so far. – Jim Pannell Nov 22 '12 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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