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?

1 Answer 1


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.

  • 1
    I would suggest a slight amendment: date_i18n( get_option( 'date_format' ), strtotime( get_the_time( "Y-m-d" ) ) );
    – vancoder
    Apr 23, 2013 at 21:07
  • 1
    @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.
    – fuxia
    Apr 23, 2013 at 21:09
  • Thanks it worked. What does 'based on timestamp' mean?
    – Gergely
    Apr 24, 2013 at 6:13
  • @GergelyBuday I made an update to my answer. :)
    – fuxia
    Apr 24, 2013 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, 2013 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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