diff --git src/wp-includes/feed-atom-comments.php src/wp-includes/feed-atom-comments.php
index 3bf0521574..49e5ca0764 100644
--- src/wp-includes/feed-atom-comments.php
+++ src/wp-includes/feed-atom-comments.php
@@ -43,8 +43,7 @@ do_action( 'rss_tag_pre', 'atom-comments' );
 	</title>
 	<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
 
-	<?php $date = get_last_build_date(); ?>
-	<updated><?php echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
+	<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
 
 <?php if ( is_singular() ) { ?>
 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" />
diff --git src/wp-includes/feed-atom.php src/wp-includes/feed-atom.php
index 16e9157b7f..bce41086be 100644
--- src/wp-includes/feed-atom.php
+++ src/wp-includes/feed-atom.php
@@ -30,8 +30,7 @@ do_action( 'rss_tag_pre', 'atom' );
 	<title type="text"><?php wp_title_rss(); ?></title>
 	<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
 
-	<?php $date = get_last_build_date(); ?>
-	<updated><?php echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
+	<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
 
 	<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" />
 	<id><?php bloginfo( 'atom_url' ); ?></id>
diff --git src/wp-includes/feed-rdf.php src/wp-includes/feed-rdf.php
index 708893245f..861425ae30 100644
--- src/wp-includes/feed-rdf.php
+++ src/wp-includes/feed-rdf.php
@@ -33,12 +33,7 @@ do_action( 'rss_tag_pre', 'rdf' );
 	<title><?php wp_title_rss(); ?></title>
 	<link><?php bloginfo_rss( 'url' ); ?></link>
 	<description><?php bloginfo_rss( 'description' ); ?></description>
-	<dc:date>
-	<?php
-		$date = get_last_build_date();
-		echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' );
-	?>
-	</dc:date>
+	<dc:date><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?>	</dc:date>
 	<sy:updatePeriod>
 	<?php
 		/** This filter is documented in wp-includes/feed-rss2.php */
diff --git src/wp-includes/feed-rss.php src/wp-includes/feed-rss.php
index 06d5f66a60..0b58d5f0ee 100644
--- src/wp-includes/feed-rss.php
+++ src/wp-includes/feed-rss.php
@@ -14,12 +14,7 @@ echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>
 	<title><?php wp_title_rss(); ?></title>
 	<link><?php bloginfo_rss( 'url' ); ?></link>
 	<description><?php bloginfo_rss( 'description' ); ?></description>
-	<lastBuildDate>
-	<?php
-		$date = get_last_build_date();
-		echo $date ? mysql2date( 'D, d M Y H:i:s +0000', $date ) : date( 'D, d M Y H:i:s +0000' );
-	?>
-	</lastBuildDate>
+	<lastBuildDate><?php echo get_feed_build_date( 'D, d M Y H:i:s +0000' ); ?></lastBuildDate>
 	<docs>http://backend.userland.com/rss092</docs>
 	<language><?php bloginfo_rss( 'language' ); ?></language>
 
diff --git src/wp-includes/feed-rss2-comments.php src/wp-includes/feed-rss2-comments.php
index c736bebccd..f8ba016b23 100644
--- src/wp-includes/feed-rss2-comments.php
+++ src/wp-includes/feed-rss2-comments.php
@@ -49,12 +49,7 @@ do_action( 'rss_tag_pre', 'rss2-comments' );
 	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
 	<link><?php ( is_single() ) ? the_permalink_rss() : bloginfo_rss( 'url' ); ?></link>
 	<description><?php bloginfo_rss( 'description' ); ?></description>
-	<lastBuildDate>
-	<?php
-		$date = get_last_build_date();
-		echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
-	?>
-	</lastBuildDate>
+	<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
 	<sy:updatePeriod>
 	<?php
 		/** This filter is documented in wp-includes/feed-rss2.php */
diff --git src/wp-includes/feed-rss2.php src/wp-includes/feed-rss2.php
index d7ddccabe0..1ba7707561 100644
--- src/wp-includes/feed-rss2.php
+++ src/wp-includes/feed-rss2.php
@@ -42,12 +42,7 @@ do_action( 'rss_tag_pre', 'rss2' );
 	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
 	<link><?php bloginfo_rss( 'url' ); ?></link>
 	<description><?php bloginfo_rss( 'description' ); ?></description>
-	<lastBuildDate>
-	<?php
-		$date = get_last_build_date();
-		echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
-	?>
-	</lastBuildDate>
+	<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
 	<language><?php bloginfo_rss( 'language' ); ?></language>
 	<sy:updatePeriod>
 	<?php
diff --git src/wp-includes/feed.php src/wp-includes/feed.php
index f8662b3055..0120e344b5 100644
--- src/wp-includes/feed.php
+++ src/wp-includes/feed.php
@@ -638,18 +638,20 @@ function self_link() {
 }
 
 /*
-* Get the timestamp of the most recently modified post from WP_Query.
-*
-* If viewing a comment feed, the date of the most recently modified
-* comment will be returned.
-*
-* @global WP_Query  $wp_query The global WP_Query object.
-*
-* @since 5.2.0
-*
-* @return string The timestamp.
-*/
-function get_last_build_date() {
+ * Get the timestamp of the most recently modified post from WP_Query.
+ *
+ * If viewing a comment feed, the date of the most recently modified
+ * comment will be returned.
+ *
+ * @global WP_Query  $wp_query The global WP_Query object.
+ *
+ * @since 5.2.0
+ *
+ * @param string $format Format of the date to return, passed to mysql2date.
+ *
+ * @return string The timestamp.
+ */
+function get_feed_build_date( $format ) {
 	global $wp_query;
 
 	if ( empty( $wp_query ) || ! $wp_query->have_posts() ) {
@@ -670,16 +672,24 @@ function get_last_build_date() {
 	}
 
 	// Determine the maximum modified time.
-	$max_modified_time = max( $modified_times );
+	$max_modified_time = max(
+		array_map(
+			function ( $time ) {
+						return mysql2date( $format, $time, false );
+			},
+			$modified_times
+		)
+	);
 
 	/**
 	 * Filters the date the last post or comment in the query was modified.
 	 *
 	 * @since 5.2.0
 	 *
-	 * @param string $max_modified_times Date the last post or comment was modified in the query.
+	 * @param string $max_modified_time Date the last post or comment was modified in the query.
+	 * @param string $format            The date format requested in get_feed_build_date.
 	 */
-	return apply_filters( 'get_last_build_date', $max_modified_time );
+	return apply_filters( 'get_feed_build_date', $max_modified_time, $format );
 }
 
 /**
