I am trying to setup a simple way of ingesting an rss feed into a Wordpress theme I designed. I have it working really well using 'fetch_feed' - all the rss items come through and I can sort them and display them how I need.
The problem I am having is the time shift. The feed I am pulling from is on an Australian server, and the actual feed dates are correct. The client server however I have no idea where it's at, but I set the time zone in the php.ini file as instructed by the hosting company, and yet all of the rss feed items are shifted by 13 hours.
Here is my code for grabbing the rss feed:
<?php // Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://xxxxxxxx.com.au/events/feed/' );
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 25.
$maxitems = $rss->get_item_quantity( 25 );
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items( 0, $maxitems );
endif;
?>
And this is the code I am using in my theme to display the feed:
<?php if ( $maxitems == 0 ) : ?>
<h3><?php _e( 'No items', 'my-text-domain' ); ?></h3>
<?php else : ?>
<?php // Loop through each feed item and display each item as a hyperlink. ?>
<?php foreach ( $rss_items as $item ) : ?>
<p><b>
<a href="<?php echo esc_url( $item->get_permalink() ); ?>" target="_blank"
title="<?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date() ); ?>">
<?php echo esc_html( $item->get_title() ); ?>
</a></b>
<?php echo esc_html( $item->get_date('| j F | g:i a') ); ?><br>
<?php echo sanitize_text_field( $item->get_content() ); ?>
</p>
<?php endforeach; ?>
<?php endif; ?>
Any help is greatly appreciated...