• artsdigital

    (@artsdigital)


    I am trying to set localised dates, but somehow the date_i18n is not displaying it correctly.

    So what I try is the following:

    $currentDate = time();
    $currentDateText = date_i18n(‘D d M Y’, $currentDate);
    

    When I have a german wp site, the date should be shown as:

    Mi. 16 Feb 2022

    But it shows as:

    Mi 16 Feb 2022

    If I understood correctly, with german dates it should have a dot next to the day.

    Any idea why it is incorrect?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If you want a dot, the format has to specify it:
    date_i18n('D. d M Y', $currentDate);

    If you have multiple locales which vary on whether there ought to be a dot or not, you could conditionally do one or the other based on get_locale() value.

Viewing 1 replies (of 1 total)
  • The topic ‘date_i18n not display correct date’ is closed to new replies.