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) ;
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
    Dec 6 '20 at 15:55
  • 1
    ok solved with echo date_i18n("d F Y (H:i)",$date) ;
    – Bondweb
    Dec 6 '20 at 16:45

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.