get_lastcommentmodified

The date the last comment was modified.

Description

(string|false) get_lastcommentmodified( (string) $timezone = 'server' ); 

Returns (string|false)

Last comment modified date on success, false on failure.

Parameters (1)

0. $timezone — Optional. (string) => 'server'
Which timezone to use in reference to gmt,, blog , or server locations.

Usage

  1. if ( !function_exists( 'get_lastcommentmodified' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // Which timezone to use in reference to 'gmt', 'blog', or 'server' locations. 
  5. $timezone = 'server'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_lastcommentmodified($timezone); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function get_lastcommentmodified( $timezone = 'server' ) { 
  2. global $wpdb; 
  3.  
  4. $timezone = strtolower( $timezone ); 
  5. $key = "lastcommentmodified:$timezone"; 
  6.  
  7. $comment_modified_date = wp_cache_get( $key, 'timeinfo' ); 
  8. if ( false !== $comment_modified_date ) { 
  9. return $comment_modified_date; 
  10.  
  11. switch ( $timezone ) { 
  12. case 'gmt': 
  13. $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" ); 
  14. break; 
  15. case 'blog': 
  16. $comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" ); 
  17. break; 
  18. case 'server': 
  19. $add_seconds_server = date( 'Z' ); 
  20.  
  21. $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 ) ); 
  22. break; 
  23.  
  24. if ( $comment_modified_date ) { 
  25. wp_cache_set( $key, $comment_modified_date, 'timeinfo' ); 
  26.  
  27. return $comment_modified_date; 
  28.  
  29. return false;