0

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
            );

1 Answer 1

0

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

<?php

$date_format = get_option( 'date_format' );

$timestamp = strtotime( get_the_time() );

$localized_date = date_i18n( $date_format, $timestamp );
4
  • Thank you for your reply! It displays the post date like this September 26, 2018 Commented Oct 9, 2018 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? Commented Oct 9, 2018 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
    Commented Oct 9, 2018 at 17:59
  • Thank you Max Yudin very much , I solved the problem :) Commented Oct 10, 2018 at 4:12

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.