• Resolved noesiskl

    (@noesiskl)


    Hello,

    since some time (new WP and/or PHP version?) the function date_i18n displays a wrong month name in calendar view (shows the right calendar sheet but the name is one month before the current). My blog settings are: timezone = ‘Berlin’, date = ‘j. F Y’, time = ‘G:i’.

    I changed date_i18n to wp_date in

    • /wp-content/plugins/events-manager/templates/templates/calendar-full.php, line 20
    • /wp-content/plugins/events-manager/templates/templates/calendar-small.php, line 17

    to fix the issue.

    FEATURE REQUEST(?): Please replace all occurences of date_i18n with wp_date according to WP developer (This is a newer function, intended to replace date_i18n() without legacy quirks in it.)

    Thanks in advance and kind regards
    Knut

    • This topic was modified 3 years, 11 months ago by noesiskl. Reason: subject enhanced

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 27 total)
  • Hello,

    Thank you for letting us know about this. I have forwarded this information to our Developers and they would review it.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Hello,

    Thanks for spotting that. We’ve changed use of date_i18n in most places but missed that one.

    We have an update coming out this week, it’ll be included there.

    same problem here, today Jan, 5 2021 I can see Dec 2021 in the title with full and small calendars

    Tried also the beta version.

    I have downgraded to version 5.9.8.1 and all works nice

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    @semperme did you try 5.9.9?

    did you try 5.9.9?

    yes, same problem, title in small and full calendar still Dec 2020

    Thread Starter noesiskl

    (@noesiskl)

    Hello,
    upgraded to 5.9.9 this moment, issue fixed.
    Thanks!
    Kind regards,
    Knut

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    @semperme could it be that you’ve overriden our templates? If so, you’d need to refresh them, or remove the ones you don’t need from your theme folder.

    They’d be in yourtheme/plugins/events-manager/templates/

    What about if you use [events_grouped mode="monthly"], does that work correctly? Because now, they’re using the same functions to generate dates.

    This is a bug that’s derived from server setups rather than WP/EM in general, which should have been fixed by using wp_date as we did in other parts of the plugin, we were never able to reproduce this ourselves, only on pro customer servers. However, we’re not allowed to request for login info via these forums.

    @netweblogic I just re-upgraded to 5.9.9

    tried with several themes, removed templates etc ..

    with shortcode all works nice, I can see Jannuary 2021 events ….

    the only problem is the Calendar widget

    I can see highlight day number when I have events, in Jannuary 2021, but the name of the month still wrong
    <td class="month_name" colspan="5">Dec 2020</td>

    so, the only problem is Calendar Widget month name

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    @semperme Thanks, it’s hard to debug things that I can’t reproduce… I think I know the issue. I used the wrong function ??

    In both these template files:

    events-manager/templates/templates/calendar-full.php
    events-manager/templates/templates/calendar-small.php

    Using a text editor, search and replace these bits:

    $EM_DateTime->format

    with

    $EM_DateTime->i18n

    and you’ll end up with something like this:

    <td class="month_name" colspan="5"><?php echo esc_html($EM_DateTime->format(get_option('dbem_full_calendar_month_format'))); ?></td>

    We’ll correct that in the next update, so when you update the fix will remain in place.

    @netweblogic I tried your suggestion but it doesn’t works, still show the past month
    esc_html($EM_DateTime->i18n(get_option...

    so, for the moment I have fixed it with
    esc_html(date_i18n(get_option ...

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    @semperme what about if you change date_i18n with wp_date? IF that doesn’t work, then your issue may be with WP rather than EM, because wp_date replaces date_i18n which is what we do in recent versions too.

    If that’s the case, the ‘easier’ option may be to just override those two templates and move onto more productive tasks ??

    We may alter those template files in the near future, but updating your code would be quite easy to do, less time spent than trying to debug this further!

    Here’s my version of a fix for the template
    https://github.com/knighthawk0811/Events-Manager-Widget-fix/blob/main/calendar-small.php

    It’s very simple and doesn’t touch anything it doesn’t need to. I used the REQUEST to get the current month/year while the users are clicking through the calendar

    Please refer to the example on this page when locating the template file on your server.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    @knighthawk thanks for the input, but bear in mind that this won’t work for users with sites other than English. wp_date and date_i18n should be able to handle this

    hopefully I’ll have the chance to look at someone’s site with this problem, then figuring out the ‘why?’ will be easier.

    Good morning I also have the same problem of the month in different language, I used the @knighthawk file by changing the months from English to Italian and deleted some comments that will appear in the widget and now it works perfectly with Italian. thanks

    @netweblogic

    I also used this change of yours a little while ago and it’s fine to see the month in Italian, because before I only came out in English
    thanks

    In both these template files:
    
    events-manager/templates/templates/calendar-full.php
    events-manager/templates/templates/calendar-small.php
    
    Using a text editor, search and replace these bits:
    
    $EM_DateTime->format
    
    with
    
    $EM_DateTime->i18n
    
    and you’ll end up with something like this:
    
    <td class="month_name" colspan="5"><?php echo esc_html($EM_DateTime->format(get_option('dbem_full_calendar_month_format'))); ?></td>
    
    We’ll correct that in the next update, so when you update the fix will remain in place.
    • This reply was modified 3 years, 10 months ago by pacc.
    • This reply was modified 3 years, 10 months ago by pacc.

    I’m having the same problem. The source of the issue appears to be that $calendar['month_start'] gets converted to the local timezone. If I dump that variable, I get “1609459200” (Friday, January 1, 2021 12:00:01 AM GMT), which is correct. When that gets converted to my local timezone, the value becomes “Thursday, December 31, 2020 6:00:00 PM GMT-06:00” which makes everything appear to be a month off.

    To fix this, on line 16 of events-manager/templates/templates/calendar-full.php, the second parameter just needs to be set to GMT. Like this:

    $EM_DateTime = new EM_DateTime($calendar['month_start'],'GMT');

    I hope this helps!

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Wrong month name in calendar’ is closed to new replies.