get_lastcommentmodified

The timeline below displays how wordpress function get_lastcommentmodified has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves the date the last comment was modified.
 *
 * @since 1.5.0
 * @since 4.7.0 Replaced caching the modified date in a local static variable
 *              with the Object Cache API.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations.
 * @return string|false Last comment modified date on success, false on failure.
 */
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;
}

WordPress Version: 5.3

/**
 * The date the last comment was modified.
 *
 * @since 1.5.0
 * @since 4.7.0 Replaced caching the modified date in a local static variable
 *              with the Object Cache API.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations.
 * @return string|false Last comment modified date on success, false on failure.
 */
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;
}

WordPress Version: 4.7

/**
 * The date the last comment was modified.
 *
 * @since 1.5.0
 * @since 4.7.0 Replaced caching the modified date in a local static variable
 *              with the Object Cache API.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations.
 * @return string|false Last comment modified date on success, false on failure.
 */
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 = date('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;
}

WordPress Version: 4.3

/**
 * The date the last comment was modified.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @staticvar array $cache_lastcommentmodified
 *
 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog',
 *		or 'server' locations.
 * @return string Last comment modified date.
 */
function get_lastcommentmodified($timezone = 'server')
{
    global $wpdb;
    static $cache_lastcommentmodified = array();
    if (isset($cache_lastcommentmodified[$timezone])) {
        return $cache_lastcommentmodified[$timezone];
    }
    $add_seconds_server = date('Z');
    switch (strtolower($timezone)) {
        case 'gmt':
            $lastcommentmodified = $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':
            $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM {$wpdb->comments} WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
            break;
        case 'server':
            $lastcommentmodified = $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;
    }
    $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
    return $lastcommentmodified;
}

WordPress Version: 4.1

/**
 * The date the last comment was modified.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog',
 *		or 'server' locations.
 * @return string Last comment modified date.
 */
function get_lastcommentmodified($timezone = 'server')
{
    global $wpdb;
    static $cache_lastcommentmodified = array();
    if (isset($cache_lastcommentmodified[$timezone])) {
        return $cache_lastcommentmodified[$timezone];
    }
    $add_seconds_server = date('Z');
    switch (strtolower($timezone)) {
        case 'gmt':
            $lastcommentmodified = $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':
            $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM {$wpdb->comments} WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
            break;
        case 'server':
            $lastcommentmodified = $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;
    }
    $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
    return $lastcommentmodified;
}

WordPress Version: 3.7

/**
 * The date the last comment was modified.
 *
 * @since 1.5.0
 * @uses $wpdb
 *
 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog',
 *		or 'server' locations.
 * @return string Last comment modified date.
 */
function get_lastcommentmodified($timezone = 'server')
{
    global $wpdb;
    static $cache_lastcommentmodified = array();
    if (isset($cache_lastcommentmodified[$timezone])) {
        return $cache_lastcommentmodified[$timezone];
    }
    $add_seconds_server = date('Z');
    switch (strtolower($timezone)) {
        case 'gmt':
            $lastcommentmodified = $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':
            $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM {$wpdb->comments} WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
            break;
        case 'server':
            $lastcommentmodified = $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;
    }
    $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
    return $lastcommentmodified;
}