diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 95e81d8eaf..88f7af44f8 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -682,7 +682,13 @@ function get_feed_build_date( $format ) { } // Determine the maximum modified time. - $max_modified_time = mysql2date( $format, max( $modified_times ), false ); + $datetime = date_create_immutable_from_format( + 'Y-m-d h:i:s', + max( $modified_times ), + new DateTimeZone( 'UTC' ) + ); + + $max_modified_time = $datetime->format( $format ); /** * Filters the date the last post or comment in the query was modified. diff --git a/tests/phpunit/tests/date/getFeedBuildDate.php b/tests/phpunit/tests/date/getFeedBuildDate.php new file mode 100644 index 0000000000..bf99ff3c26 --- /dev/null +++ b/tests/phpunit/tests/date/getFeedBuildDate.php @@ -0,0 +1,39 @@ +post->create( + array( + 'post_date' => '2018-07-22 21:13:23', + 'post_date_gmt' => '2018-07-23 03:13:23', + ) + ); + + $wp_query = new WP_Query( array( 'p' => $post_id ) ); + + $this->assertEquals( '2018-07-23T03:13:23+00:00', get_feed_build_date( DATE_RFC3339 ) ); + } +}