I'm trying to translate the post date using __() function. But it is not working. The post date still displayed in English.

What are you the other options to localize the post date(posted-on).

 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

It depends how and where you use this string. Possibly, you have to localize the date according to the site settings:


$date_format = get_option( 'date_format' );

$timestamp = strtotime( get_the_time() );

$localized_date = date_i18n( $date_format, $timestamp );
  • Thank you for your reply! It displays the post date like this September 26, 2018 Oct 9 '18 at 13:07
  • Should I implement the $date_format, $timestamp, $localized_date in inc/functions.php because I'm using the the strings in the same file? Oct 9 '18 at 13:14
  • Just mention the file where do you use it and show us the code! It becomes much more funny and useful when other people can find something they are search for!
    – Max Yudin
    Oct 9 '18 at 17:59
  • Thank you Max Yudin very much , I solved the problem :) Oct 10 '18 at 4:12

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.