Posted: November 26, 2013 at 5:48 pm
|
Hello EE Folks! I’ve got another question about displaying the Event Start / End time. Right now, I have the following in my event_post.php file (in the templates directory, of course): <p><?php echo date(‘l M jS, Y g:i a’,strtotime($start_date)) . ” – ” . date(‘l M jS, Y g:i a’,strtotime($end_date)); ?></p> This is displaying the proper format (Friday Nov 29th, 2013 12:00 am) but the start and end time display as 12:00 am even though there is a defined start / end time. What do I need to do in order to show the start / end time properly? Thanks! |
|
Hi, This is because the start date and start time are separate, so you are trying to display the time on something that doesn’t have it or has the default. I would use this instead <?php echo event_date_display($start_date, get_option('date_format')); echo " "; //just a space echo event_date_display($event->start_time, get_option('time_format')); echo " - "; echo event_date_display($end_date, get_option('date_format')); echo " "; //just a space echo event_date_display($event->end_time, get_option('time_format')); ?> You can replace the get_option(‘date_format’) with (‘m/d/Y’) etc. |
|
Thanks Dean! That’s now displaying the Start / End as “11/29/2013 β 11/29/2013” (http://www.climbcrux.org/2013/10/friday-night-climb-at-brooklyn-boulders-nov-29-2013/) and still not showing the start / end times. Also, if I wanted to change the format of the date to be “Friday Nov 11th, 2013” rather than “11/29/2013” how do I do that? I tried replacing (‘date_format’) with (‘l M jS, Y’) but that did not work. π |
|
Odd, it’s working for me – http://d.pr/i/zf07 Format wise, instead of echo event_date_display($end_date, get_option('date_format')); it would be echo event_date_display($end_date, ('d-m-Y'); |
|
Hey Dean… Still no Start / End times. I’ve updated the date format, and that’s working, but no start / end times. Here’s the code I have: <code></php /* the below section changed to include the event start and event end time when looking at event posts */ ?> <?php echo event_date_display($start_date, ('l M jS, Y')); echo " "; //just a space echo event_date_display($event->start_time, get_option('time_format')); echo " - "; echo event_date_display($end_date, ('l M jS, Y')); echo " "; //just a space echo event_date_display($event->end_time, get_option('time_format')); ?></code> I’m working on one event for now until I get this right. If you look at the calendar (http://www.climbcrux.org/eventscalendar) for November 29th, there’s an event from 7pm – 10pm. When you click that event, it shows the Date / Time as “Friday Nov 29th, 2013 β Friday Nov 29th, 2013” Could there be a setting somewhere I’m missing? |
|
Hi, I’m just not sure why it isn’t working for you. I added the above code to a new site running the latest EE (though your version will be the same) and it gave me this http://d.pr/i/sx15 so the code works, settings shouldn’t be an issue here. If you can add the entire template code to a pastebin (http://pastebin.com/) I can add it to a test site and maybe there is something else in your code that is making this not work. I am assuming you are adding this to the event_registration_page_display.php file? |
|
Hi Dean… I think we’ve found the issue. π The Registration Page works just fine (http://www.climbcrux.org/event-registration/?ee=233). What I’m trying to do is add the Start / End time to the WordPress event post, not the registration page. I’ve had several people complain that when we link to the event post, on Facebook for instance, the post itself has no start / end time; users have to go to the registration page to see that information. (Event Post — http://www.climbcrux.org/2013/10/crux-first-fridays-friday-night-climb-at-brooklyn-boulders-new-climbers-welcome-2/) Am I correct that if I want to modify the way the WordPress post is created, I should be making these changes to event_post.php? |
|
Hi, I am sorry I completely missed that! Yes the event_post.php needs to be edited, something liek this at line 274 <p><?php echo event_date_display($start_date, get_option('date_format')) . " " . $data->event->start_time . " - " . event_date_display($end_date, get_option('date_format')) . " " . $data->event->end_time; ?></p> You will need to update the Event before the post will reflect any changes. |
|
Hi Dean, we’re almost there! Now the last question is how to update the format for the time from 24hr time to 12hr time. Right now I’m seeing 19:00 – 22:00 rather than 7pm – 10pm, and I don’t see in the code you provided any way to modify the display format for the time. Thanks! |
|
Hi, You will need to use the Date format (works for time too) http://php.net/manual/en/function.date.php <p><?php echo event_date_display($start_date, get_option('date_format')) . " " . date('h:i a', strtotime($data->event->start_time)) . " - " . event_date_display($end_date, get_option('date_format')) . " " . date('h:i a', strtotime($data->event->end_time)); ?></p> |
|
Dean, you’re the best! I knew I had to update the Date format display, but wasn’t sure what the PHP code to do that was. The $data->event->end_time was giving me fits. It’s all fixed now though. Thanks so much! |
The support post ‘Display Event Start / End Time in Event Post’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.