WordPress.org

Ready to get started?Download WordPress

Forums

Events Calendar
Problem with hours (4 posts)

  1. Nextstudio
    Member
    Posted 2 years ago #

    Hello. I have installed this plugin and works perfectly in WordPress 3.3.1, but I do not want to put the hours in the events field, but although the field is empty, in the end always leaves “00: 00: 00”. How I can avoid it?.

    Thanks

    NextStudio

    http://wordpress.org/extend/plugins/events-calendar/

  2. Ruturaaj Patki
    Member
    Posted 1 year ago #

    Yes. I faced the same issue and attempted to trace the cause of it. I think this has something to do with MySQL. The Events Calendar plugin stores its data in separate database table "[prefix]_eventcalendar_main". I checked the structure of table and found that endTime and startTime are set as "Time" data type. So somewhere the "NULL" is getting translated as "00:00:00".

    I know this thread is one month old; but just wish to keep my work-around trick posted here for others. I'm sure there must be some other better way of avoiding it; for me, it was truly a time sensitive issue as the dead-line was approaching fast! :-)

    Open "ec_js.class.php" file and find the function "calendarDataLarge" (since I wanted to make correction on front-end; not much worried about Admin; I know Admin is smart enough to clear the fields whenever he edits the event data!).

    Scroll down the function-code until you find following line:

    $startTime = date($options['timeFormatLarge'], mktime($ec_starthour, $ec_startminute, $ec_startsecond, $ec_startmonth, $ec_startday, $ec_startyear));

    Add following code below it:

    if ($startTime == '12:00 am')
    {
        $startTime = null;
    }

    Similarly, find the similar code-line for $endTime and add above code with corrections in variable names of course. This should show the Start Time only if you put in. The down-side of this trick (and the reason why I strongly believe a better solution must exist) is that you ever won't be able to specify "00:00:00" as your Start Time or End Time for any Event. In my case, it couldn't have been the case ever, so the above work-around was good for me to go with and complete the project in time.

    Now that I may require to use this plugin again in another project, I think it's time again to look into this issue and find a better solution. Your suggestions are welcome! :-)

    Cheers,

    Ruturaj.

  3. grantpolachek
    Member
    Posted 1 year ago #

    This works perfectly for the calendar. What if your using the widget in list mode?
    http://www.millrose1.microshareinternetmarketing.com/

  4. svendelmaus
    Member
    Posted 1 year ago #

    After a bit of mucking about inside ec_db.class.php, it looks like there's something odd happening once the values are handed off to the $wpdb global object to be inserted/updated. The $startDate appears to be being correctly set to NULL before being handed off to $wpdb, and I've determined that the calendar does what you'd expect if you go directly into the database and change the field eventEndTime, replacing the value '00:00:00' with NULL. So it looks like WordPress is helpfully changing the NULL back into '0' before inserting it into the table.

    Unfortunately, that is as far as I have gotten. I don't know if this a recently introduced bug, or the best way to fix it -- it feels a bit odd to mask the problem as suggested above, since it means that you can never actually use midnight properly. But if you were going to use this hack, it might be a good idea to introduce it slightly earlier in the chain -- getDaysEvents, getEvent and getUpcomingEvents in the ec_db.class.php file would make sure that it was "fixed" everywhere. But it's probably the wrong solution anyway.

    Does anyone know more about the $wpdb global object? Does this provide a clue to anyone more knowledgeable?

    This is WordPress Version 3.4.2, and Version 6.7.13 of the calendar plugin, fwiw.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic