• I am displaying some events on the front end of a site I am developing, and I’m trying to display each event’s time like this:

    $em_event = new EM_Event( $post->ID );
    
    echo $em_event->output( '#_EVENTTIMES' );

    But the #_EVENTTIMES placeholder just outputs the site’s current time (e.g. “7:53 pm – 7:53 pm”), rather than the real range for each event. I tried the #_12HSTARTTIME placeholder, and it showed the correct start time for each event. I haven’t tracked this down in the code yet, but it seems like it must be a bug. I tried searching but I couldn’t find anyone else experiencing it.

    We are using multisite, by the way.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter J.D. Grimes

    (@jd55)

    I checked the other time placeholders, and all are working properly, except #_EVENTTIMES.

    I also checked the date/time format settings, and the time format is g:i a. I’m not sure if that has been changed from the default or not.

    Thread Starter J.D. Grimes

    (@jd55)

    I just noticed that the #_EVENTDATES placeholder isn’t working either. It is also showing the current date, rather than the real date for each event. I guess these two placeholders somehow work differently than the other time placeholders? I’m going to dig into this further and see what I can find.

    Thread Starter J.D. Grimes

    (@jd55)

    I think I know why this is happening. I looked at /classes/em-event.php, and here is what I found. The #_EVENTDATES and #_EVENTTIMES placeholders are displayed using the WordPress function date_i18n(). It uses the class vars $start and $end and passes them to date_i18n() as the timestamps for the start and end time/date respectively. The other time placeholders (#_24HSTARTTIME #_24HENDTIME #_12HSTARTTIME #_12HENDTIME) use the class vars $event_start_time and $event_end_time. So these are two placeholders do indeed work a little bit differently than the others.

    So why is the current time being displayed? It turns out that date_i18n() displays the current time by default. This will only happen, however, when boolean false is supplied as the timestamp parameter. Like I said above, the $start and $end class variables are supplied to the function on each time it is called, respectively. These variables are loaded on lines 299 and 300, using strtotime(). This function returns false on failure, so apparently that is the problem.

    $this->event_start_date." ".$this->event_start_time must not be a valid time in this case. Why?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    don’t know if this is a bug but it works okay on my test site; e.g. #_EVENTTIMES => 7:00 pm – 8:45 pm

    however is this using recurring events or just normal events?

    Thread Starter J.D. Grimes

    (@jd55)

    This is just using regular events.

    I’ve found that the value of $start and $end are actually the current timestamp. How could that be happening? When I manually generate the timestamp like this, it is correct:

    $em_event = new EM_Event( $post->ID );
    
    strtotime( $em_event->event_start_date . " " . $em_event->event_start_time )

    I don’t see anything in the docs about strtotime() returning the current time automatically. So the values of $event_start_date and $event_end_date must change after $start and $end are loaded, or $start and $end get reset somewhere. I don’t see anything like that in the code though.

    Thread Starter J.D. Grimes

    (@jd55)

    Here’s how I’m getting around it for now, though I would still like to figure out what is going on here.

    I’m outputting the dates like this:

    $em_event->output( '#_{j M Y} #@_{ \t\o j M Y}' );

    Works beautifully! But if I do this:

    $em_event->output( '#_EVENTDATES' );

    Or this:

    $em_event->output( '#j #M #Y to #@j #@M #@Y' );

    It just displays the current time.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    works for me, did you try $EM_Event = em_get_event($post->ID, 'post_id'); ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘#_EVENTTIMES shows current time.’ is closed to new replies.