So I purchased a premium wordpress theme, but I can't get through its Polish localization - the dates outside the_time or the_date are displaying in English (default server's language). I read that I have to use setlocale(LC_ALL, 'pl_PL'); to change it, but I don't know in which file or where it should be included and/or if I need something more. Below is an excerpt of code displaying English date:

$event_date = get_post_meta(get_the_ID(), 'event_date');
$event_from_time = get_post_meta(get_the_ID(), 'event_from_time');
$event_to_time = get_post_meta(get_the_ID(), 'event_to_time');
$event_address = get_post_meta(get_the_ID(), 'event_address');

echo date('j F Y', strtotime($event_date[0])).'  '.$event_from_time[0].' do '.$event_to_time[0];

I appreciate your time and help.

1 Answer 1


Use date_i18n( $format, $i );

echo date_i18n('j F Y', strtotime( $event_date[0] ) ) 
    . '  '
    . date_i18n('j F Y', strtotime( $event_from_time[0] ) ) 
    . ' do '
    . date_i18n('j F Y', strtotime( $event_to_time[0] ) );

See also: How to integrate get_post_time with date_i18n function?

  • thx for the answer and the read, it works great. however any idea why date_i18n does not work with the abbreviated month ('M')?
    – gipson
    Jun 13, 2013 at 19:54
  • @gipson M should work fine (not every format will since date_i18n() essentially emulates format support rather than using native PHP stuff), just tested.
    – Rarst
    Jun 13, 2013 at 20:05
  • @Rarst My bad. Thx for your help guys!
    – gipson
    Jun 13, 2013 at 20:21

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.