Title: get_feed_build_date
Published: May 7, 2019
Last modified: February 24, 2026

---

# get_feed_build_date( string $format ): string|false

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#wp--skip-link--target)

Gets the UTC time of the most recently modified post from [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/).

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#description)󠁿

If viewing a comment feed, the time of the most recently modified comment will be
returned.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#parameters)󠁿

 `$format`stringrequired

Date format string to return the time in.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#return)󠁿

 string|false The time in requested format, or false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#source)󠁿

    ```php
    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.
    		$datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', max( $modified_times ), $utc );
    	}

    	if ( false === $datetime ) {
    		// Fall back to last time any post was modified or published.
    		$datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', get_lastpostmodified( 'GMT' ), $utc );
    	}

    	if ( false !== $datetime ) {
    		$max_modified_time = $datetime->format( $format );
    	}

    	/**
    	 * Filters the date the last post or comment in the query was modified.
    	 *
    	 * @since 5.2.0
    	 *
    	 * @param string|false $max_modified_time Date the last post or comment was modified in the query, in UTC.
    	 *                                        False on failure.
    	 * @param string       $format            The date format requested in get_feed_build_date().
    	 */
    	return apply_filters( 'get_feed_build_date', $max_modified_time, $format );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/feed.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/feed.php#L715)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/feed.php#L715-L758)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_feed_build_date’, string|false $max_modified_time, string $format )](https://developer.wordpress.org/reference/hooks/get_feed_build_date/)

Filters the date the last post or comment in the query was modified.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Query::is_comment_feed()](https://developer.wordpress.org/reference/classes/wp_query/is_comment_feed/)`wp-includes/class-wp-query.php` |

Determines whether the query is for a comments feed.

  | 
| [WP_Query::have_posts()](https://developer.wordpress.org/reference/classes/wp_query/have_posts/)`wp-includes/class-wp-query.php` |

Determines whether there are more posts available in the loop.

  | 
| [wp_list_pluck()](https://developer.wordpress.org/reference/functions/wp_list_pluck/)`wp-includes/functions.php` |

Plucks a certain field out of each object or array in an array.

  | 
| [get_lastpostmodified()](https://developer.wordpress.org/reference/functions/get_lastpostmodified/)`wp-includes/post.php` |

Gets the most recent time that a post on the site was modified.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_feed_build_date/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_feed_build_date%2F)
before being able to contribute a note or feedback.