Change pubDate in rss feed in another format

In the default wordpress rss feed the element pubDate is

pubDate?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?/pubDate

and gives a result of pubDateTue, 12 May 2020 12:39:03 +0000/pubDate

how can i change this line to give a result of pubDate12/05/2020 12:39:03 +0000/pubDate (d/m/Y) or pubDate12-05-2020 12:39:03 +0000/pubDate (d-m-Y) but to be valid with RFC-822 ?

I tried many variations pubDate?php echo mysql2date('r', get_the_time('Y-m-d H:i:s')); ?/pubDate or pubDate?php echo get_post_time( 'd/m/Y H:i:s O', true ); ?/pubDate but they dont validate.

Any ideas would be appreciated.

Topic date validation timestamp feed rss Wordpress

Category Web


Where are you validating your feed, and what is the error you are seeing?

Most likely you simply need to wrap the time in CDATA. Looking at an existing feed from wordpress you can see the example:

Try replacing your pubDate with the CDATA version and see if it validates!


You can probably do this by customizing the feed:

https://codex.wordpress.org/Customizing_Feeds

This way you can make your own template for a feed, and alter the pubDate to your needs.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.