Title: get_lastcommentmodified
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_lastcommentmodified( string $timezone = ‘server’ ): string|false

## In this article

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

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

Retrieves the date the last comment was modified.

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

 `$timezone`stringoptional

Which timezone to use in reference to `'gmt'`, `'blog'`, or `'server'` locations.

Default:`'server'`

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

 string|false Last comment modified date on success, false on failure.

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

    ```php
    function get_lastcommentmodified( $timezone = 'server' ) {
    	global $wpdb;

    	$timezone = strtolower( $timezone );
    	$key      = "lastcommentmodified:$timezone";

    	$comment_modified_date = wp_cache_get( $key, 'timeinfo' );
    	if ( false !== $comment_modified_date ) {
    		return $comment_modified_date;
    	}

    	switch ( $timezone ) {
    		case 'gmt':
    			$comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
    			break;
    		case 'blog':
    			$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
    			break;
    		case 'server':
    			$add_seconds_server = gmdate( 'Z' );

    			$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
    			break;
    	}

    	if ( $comment_modified_date ) {
    		wp_cache_set( $key, $comment_modified_date, 'timeinfo' );

    		return $comment_modified_date;
    	}

    	return false;
    }
    ```

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

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

| Uses | Description | 
| [wp_cache_set()](https://developer.wordpress.org/reference/functions/wp_cache_set/)`wp-includes/cache.php` |

Saves the data to the cache.

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

Retrieves the cache contents from the cache by key and group.

  | 
| [wpdb::get_var()](https://developer.wordpress.org/reference/classes/wpdb/get_var/)`wp-includes/class-wpdb.php` |

Retrieves one value from the database.

  | 
| [wpdb::prepare()](https://developer.wordpress.org/reference/classes/wpdb/prepare/)`wp-includes/class-wpdb.php` |

Prepares a SQL query for safe execution.

  |

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

| Used by | Description | 
| [WP::send_headers()](https://developer.wordpress.org/reference/classes/wp/send_headers/)`wp-includes/class-wp.php` |

Sends additional HTTP headers for caching, content type, etc.

  |

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

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Replaced caching the modified date in a local static variable with the Object Cache API. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

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