WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the birdtips theme and it formats the post date as

$birdtips_posted = date(__('Y. F j.', 'birdtips'),  strtotime(get_the_time("Y-m-d")));

where Y. F j. is already rewritten to reflect my language. As far as I understand, __ is the translation function, but how can I tell Wordpress that I use Hungarian, and will it translate month names automatically, or I should give the names in a .po file?

share|improve this question
up vote 4 down vote accepted

Use date_i18n():

date_i18n( 'Y. F j.',  strtotime( get_the_time( "Y-m-d" ) ) );

From the function’s description:

Retrieve the date in localized format, based on timestamp.

If the locale specifies the locale month and weekday, then the locale will take over the format for the date. If it isn't, then the date format string will be used instead.

A timestamp is a UNIX timestamp, a single number, for example 1366784091.

share|improve this answer
I would suggest a slight amendment: date_i18n( get_option( 'date_format' ), strtotime( get_the_time( "Y-m-d" ) ) ); – vancoder Apr 23 '13 at 21:07
@vancoder This is correct when you don’t know the context. When you change code for a personal use case you don’t need the same format in all places. – toscho Apr 23 '13 at 21:09
Thanks it worked. What does 'based on timestamp' mean? – Gergely Apr 24 '13 at 6:13
@GergelyBuday I made an update to my answer. :) – toscho Apr 24 '13 at 6:16
@toscho: well, I misunderstood the sentence, the date is based on the timestamp, but the localized format is based on the locale. – Gergely Apr 24 '13 at 6:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.