function get_feed_build_date( $format ) { global $wp_query;
$datetime = false;
$max_modified_time = false;
$utc =
new DateTimeZone( 'UTC'
);
if ( !
empty( $wp_query ) &&
$wp_query->
have_posts() ) { // Extract the post modified times from the posts.
$modified_times =
wp_list_pluck( $wp_query->posts, 'post_modified_gmt'
);
// If this is a comment feed, check those objects too.
if ( $wp_query->
is_comment_feed() &&
$wp_query->comment_count
) { // Extract the comment modified times from the comments.
$comment_times =
wp_list_pluck( $wp_query->comments, 'comment_date_gmt'
);
// Add the comment times to the post times for comparison.
$modified_times =
array_merge( $modified_times,
$comment_times );
} // Determine the maximum modified time.