Day for the date in english for rss feed only
-
Hello
Further this topic here : https://www.ads-software.com/support/topic/start-and-end-date-in-the-rss-feed/
I added my start date et en date for my rss feed. I have only a problem the day is in french, so : mer, 10 Jan 2024 00:00:00 +0000 and I need to have the day in english : Wed, 10 Jan 2024 00:00:00 +0000
How can I fix that please?
-
Hi @houba_houbi
Thanks for your message.
Can you share the code snippet that you used to add the start date in your RSS feed? Also, please provide the URL of the page where your RSS feed is located so that I can check it on my end. This will help me to investigate it further.
Looking forward to your reply.
Hi @darian
Here is the code :
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> <?php if ( tribe_get_start_date() !== tribe_get_end_date() ) { ?> <dc:date><?php echo tribe_get_start_date( $event_id, true, 'D, d M Y H:i:s +0000' ); ?></dc:date> <lmp:endDate><?php echo tribe_get_end_date( $event_id, true, 'D, d M Y H:i:s +0000' ); ?></lmp:endDate> <?php } else { ?> <dc:date><?php echo tribe_get_start_date( $event_id, true, 'D, d M Y H:i:s +0000' ); ?></dc:date> <?php } ?>
PubDate day is in english but the dc:date and lmp:endDate are in french
The feed here (on a test website) : https://demo.crealys-web.net/wordpress/feed/lumiplan-evenements
Thanks
Hi @houba_houbi,
Could you try replacing the snippet you provided by the one below and see if that makes a difference?
<pubDate> <?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <?php $my_days = [ "lun" => "Mon", "mar" => "Tue", "mer" => "Wed", "jeu" => "Thu", "ven" => "Fri", "sam" => "Sat", "dim" => "Sun", ]; if ( tribe_get_start_date() !== tribe_get_end_date() ) { $start_date = tribe_get_start_date( $event_id, true, 'D, d M Y H:i:s +0000' ); $temp_day = substr($start_date, 0, 3); if(isset($my_days[$temp_day])){ $start_date = str_replace($temp_day, $my_days[$temp_day], $start_date); } $end_date = tribe_get_end_date( $event_id, true, 'D, d M Y H:i:s +0000' ); $temp_day = substr($end_date, 0, 3); if(isset($my_days[$temp_day])){ $end_date = str_replace($temp_day, $my_days[$temp_day], $end_date); } ?> <dc:date> <?php echo $start_date; ?> </dc:date> <lmp:endDate> <?php echo $end_date; ?> </lmp:endDate> <?php } else { ?> <dc:date> <?php echo $start_date; ?> </dc:date> <?php } ?>
As always, please test it first on your staging site to avoid unnecessary downtime in your live site.
Let me know how it goes.
Thanks Darian, almost !
Strange thing for dates with no end date : the date is not displaying or false :
https://1drv.ms/w/s!Ao_ahcfnOc5QnYIuUzXXpVSdwIrjEg?e=a9HZ84
And all the date is not in english,for example december : Déc => Dec
- This reply was modified 11 months, 1 week ago by houba_houbi.
Hi @houba_houbi
Could you try the code below and see if the month is correctly translated? I’m not sure for June and July if they are correct because they both start with
Jui
.<pubDate> <?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <?php $my_days = [ "lun" => "Mon", "mar" => "Tue", "mer" => "Wed", "jeu" => "Thu", "ven" => "Fri", "sam" => "Sat", "dim" => "Sun", ]; $my_months = [ "Jan" => "Jan", "Fév" => "Feb", "Mar" => "Mar", "Avr" => "Apr", "Mai" => "May", "Jui" => "Jun", "Jui" => "Jul", "Ao?" => "Aug", "Sep" => "Sep", "Oct" => "Oct", "Nov" => "Nov", "Déc" => "Dec", ]; $start_date = tribe_get_start_date( $event_id, true, 'D, d M Y H:i:s +0000' ); $temp_day = substr($start_date, 0, 3); $temp_month = substr($start_date, 8, 10); if(isset($my_days[$temp_day])){ $start_date = str_replace($temp_day, $my_days[$temp_day], $start_date); } if(isset($my_months[$temp_month])){ $start_date = str_replace($temp_month, $my_months[$temp_month], $start_date); } if ( tribe_get_start_date() !== tribe_get_end_date() ) { $end_date = tribe_get_end_date( $event_id, true, 'D, d M Y H:i:s +0000' ); $temp_day = substr($end_date, 0, 3); $temp_month = substr($end_date, 8, 10); if(isset($my_days[$temp_day])){ $end_date = str_replace($temp_day, $my_days[$temp_day], $end_date); } if(isset($my_months[$temp_month])){ $end_date = str_replace($temp_month, $my_months[$temp_month], $end_date); } ?> <dc:date> <?php echo $start_date; ?> </dc:date> <lmp:endDate> <?php echo $end_date; ?> </lmp:endDate> <?php } else { ?> <dc:date> <?php echo $start_date; ?> </dc:date> <?php } ?>
Let me know how it goes.
Hello thank you so much, works great.
It’s a mystery for me french month “jui” and “jui” are ok in english !
Hi @houba_houbi
Thanks for your confirmation and I’m glad that it is now working.
If you have a minute, a great review from you would be amazing!
https://www.ads-software.com/support/plugin/the-events-calendar/reviews/
I’ll close this thread for now, but please do not hesitate to start a new thread if you have other issues at all. This allows us to track topics/issues efficiently and follow the WordPress Forum Guidelines.
- The topic ‘Day for the date in english for rss feed only’ is closed to new replies.