I want to translate the post meta data (date) in chines language for example, September 13, 2017, should be translated as 2017年9月13. But my code gives it in English. Do you see any error? Please help.

Thank you in advance.

  $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
        if (get_the_time('U') !== get_the_modified_time('U')) {
            $time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';

        $time_string = sprintf($time_string,
        printf(__('<span class="posted-on"><a href="%1$s" title="%2$s" rel="bookmark"><i class="fa fa-clock-o"></i> %3$s</a></span>', 'colormag'), 
            esc_url(get_permalink()), esc_attr(get_the_time()), $time_string
  • The Codex says to use date_i18n.
    – Hans
    Oct 7, 2018 at 8:47
  • inside the printf i used __() to localize. But still the same Oct 7, 2018 at 13:45
  • How do I use date_i18n ? Oct 7, 2018 at 13:57
  • Example is from the Codex: <?php echo date_i18n( get_option( 'date_format' ), strtotime( '11/15-1976' ) ); ?>
    – user141080
    Oct 7, 2018 at 14:30
  • May you give an example with printf please Oct 7, 2018 at 14:36

1 Answer 1


You don't need to change any code.

get_the_date without an argument will use the date_format option in your WordPress settings. The option F j, Y will substitute F as "September", but if you have a translation of "September" it will be used.

Comments have suggested the use of date_i18n. This is used automatically when you call get_the_date(). Translations of the days and months are in WordPress core and will be used if installed. e.g. The Chinese translation of "September" is here,

However, if you want to print "2017年9月13" I think you will have to set a custom format in your WordPress settings as:


Under Settings > General > Date Format, select "Custom" and enter that into the field. I've tested that and it formats the Chinese characters just fine.

  • Hi Tim, Thank you very much! Yes date_i18n and i10n are already installed in wordpress as you said. I fixed it from setting after two days. Thank you again! :) Oct 12, 2018 at 2:16
  • OK good. Please accept my answer if it's correct.
    – Tim
    Oct 12, 2018 at 7:36
  • Your answer is correct, How do I accept?I newly joined the Forum, I already voted up, a message fleshed " Your vote is counted but will not appear as your reputation is less. " Oct 12, 2018 at 9:56
  • Click the grey tick on the left of the answer, below the up/down arrows
    – Tim
    Oct 12, 2018 at 12:15
  • Your answer seems to be a better choice. But how to use a custom translation for the date, instead of WordPress installed ones. E.g. WordPress installed translations are in their language format, but I want to use my own translation that is written in English letters. So how to use my translation? Aug 1, 2020 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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