0

I'm using this filter to display post date in my single and archive pages, because working on a windows azure php app I can't show post date before 1901.

This filter is working but It displays post date in english

add_filter( 'get_the_date', function($the_date, $d, $post){
  $date = new DateTime( $post->post_date );
 echo $date->format('j F, Y'); // change formatting as needed 
}, 10, 3 );

I need to display the post date in italian. How can I do that?

Thanks guys

ok I solved with

echo date_i18n("d F Y (H:i)",$date) ;

1 Answer 1

0

for example use:
_e('the things to print')

or if woocommerce is being used its possible to use this way:
_e('the things to print', 'woocommerce')

add_filter( 'get_the_date', function($the_date, $d, $post){
  $date = new DateTime( $post->post_date );
  echo _e($date->format('j F, Y')); // change formatting as needed 
}, 10, 3 );

for more information about _e()

the text is translated for the wordpress language choosen by the administrator in Dashboard > settings > general

2
  • Hi Tiago, thanks for your answer but it doesn't works. In Dashboard > settings > general I set Italian, but it shows always j F, Y in english
    – Bondweb
    Commented Dec 6, 2020 at 15:55
  • 1
    ok solved with echo date_i18n("d F Y (H:i)",$date) ;
    – Bondweb
    Commented Dec 6, 2020 at 16:45

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.