I have a WordPress site and I am using a plugin to manage registrations to events (the plugin name is Events Manager Pro).
With this plugin, we are allowed to create placeholders to display various information on events webpages.
I created a placeholder to show the date and time when registrations to an event starts. The name I gave to my placeholder is: #_REGISTRATIONSTARTDATETIME
I use this code in the function.php file of my child theme:
function my_em_registrationstartdatetime_placeholder($replace, $EM_Event, $result){
if ( $result == '#_REGISTRATIONSTARTDATETIME' ) {
$ticket_list = "";
foreach( $EM_Event->get_tickets()->tickets as $EM_Ticket ){
$ticket_list .= $EM_Ticket->get_datetime('start');
}
$replace = $ticket_list;
}
return $replace;
}
add_filter('em_event_output_placeholder','my_em_registrationstartdatetime_placeholder',1,3);
My problem is the date and time is output in this format: 2023-01-09 10:00:00
I wish to have the date and time output in this format instead: Monday January 9 at 10h00
Thank you!
My knowledge in PHP is limited. I am sorry, but I am eager to learn. Does anyone know what could be modified in my PHP code to format the date and time?
2
Answers
Thank you. It now works.
Here is the code I have in my functions.php file :
In the functions.php file, I also added the code recommended in the link suggested by Moishy : https://mediarealm.com.au/articles/wordpress-timezones-strtotime-date-functions/.
use
wp_date
function and php date format parametersto add a timezone to it, add a
DateTimeZone
argument to the function. For example: