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.
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.
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?
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?
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.
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.
works for me, did you try $EM_Event = em_get_event($post->ID, 'post_id');
?